Monday, May 27, 2013

Solution for failed to run yiic

This is a common error we usually get if we did not redirect correctly to YiiRoot path.

PHP Warning:  require_once(/home/projectname/protected/../YiiR                                                                oot/framework/yiic.php): failed to open stream: No such file or directory in /ho                                                                me/projectname/protected/yiic.php on line 7

PHP Fatal error:  require_once(): Failed opening required '/home/projectname/protected/../YiiRoot/framework/yiic.php' (include_path='.:/usr/sh                                                                are/pear:/usr/share/php') in /home/projectname/protected/yiic.php on line 7

Step 1:
Check the following file:
- index.php 
Change the following path according to your YiiRoot path
$yii=dirname(__FILE__).'/../../YiiRoot/framework/yii.php';

Step 2:
- projectname/protected/yiic.php
Change the following path according to your YiiRoot path
$yiic=dirname(__FILE__).'/../../YiiRoot/framework/yiic.php';



Sunday, May 12, 2013

How to use xmlrpc in Drupal 7


I'm new to Drupal but after grance thru many article, this is the most easier for me to understand.

Here is the references link: http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_xmlrpc/7

But you may read my finding too. :)

Step 1:
Add the piece of code in sites\yourproject\modules\custom\yourmodule

function yourmodule_xmlrpc() {
  return array(
    'yourmethodName' => 'yourfunctionName',
    array(
      'yourmethodName',      'yourfunctionName',      array(  // The element might be diff and it base on application call back and answer
        'boolean',  //The first element of this array is the type of return value 
        'string',   //You can do just answer or more elements
        'string',
        'string',
        'string',
        'string',
      ),
      t('Handling ping request'),
    ),
  );
}

Step 2:
Add the piece of code in sites\yourproject\modules\custom\yourmodule
// Assume you need to save parameter4 which is array into node table
function yourfunctionName($parameter1, $parameter2, $parameter3, $parameter4) {        
      foreach($parameter4 as $arr){
            $node = new stdClass();
            $node->type ='contenttypename';
            $node->uid = 1;
            $node->title = $arr['title'];
            $node->status;
            $node->body[$node->language][0]['format'] = 'full_html';
            $node->body[$node->language][0]['summary'] = text_summary($arr['body']);
            $node->body[$node->language][0]['value']   = $arr['body'];
            if($node = node_submit($node)){
                 node_save($node);
           }
       }
      $answer = array('code', 'record saved');
      return $answer;   // 
}

Thursday, April 11, 2013

Step By Step Setup YiiBoilerPlate


Yii Boilerplate Installation Guides:

1. Download YiiBoilerplate from https://github.com/clevertech/YiiBoilerplate

2. Map admin.domainname.com (or similar) to backend > www
   Map domainname.com (or similar) to frontend > www (if required)

3. Create database for app
   Create database for test with suffix _test (if required)

4. Add db details to common > config > params-local.php

5. Remove comments from db connections in console > config > main.php
   Remove comments from db connections and gii in backend > config > main.php
   Remove comments from db connections in frontend > config > main.php (if required)

6. Run the following command
   ./runpostdeploy local non-migrate
   ./yiic migrate

Yii Boilerplate Get Start:

** Please chmod 777 for the following file and folder
- yiic and runpostdeploy
- backend/views
- backend/controllers
- backend/models

1. Run the following command to create table in mysql
   ./yiic migrate create create_tablename

2. Goto folder console/migration/ and find the file to add in table stucture

3. Run the following command after edit migration file
   ./yiic migrate

4. Goto backend/config/main.php to uncomment Gii section and save the file

5. You can browse Gii with the following path and start work with your MVC
   http://xxx.dev/backend/www/gii/default/index

To Enable Gii

1. Goto backend/config/main.php

2. uncomment Gii

3. Add the following code in Gii section, else you will get error 403
   'ipFilters' => array('127.0.0.1', $_SERVER['REMOTE_ADDR']),

To Browse Gii

1. Goto http://yourdomain.com/backend/www/gii/model/


*********************  HAPPY CODING!! ******************

Monday, December 3, 2012

On Screen Keyboard with VB6

http://www.vbforums.com/showthread.php?508872-on-screen-keyboard-using-VB6


Private Sub cmdKey_Click(Index As Integer)
Static boShift As Boolean
Dim strInput As String
Dim intASC As Integer
If Index = 1 Then
    boShift = Not boShift
    If boShift = True Then
        cmdKey(1).Caption = "SHIFT (ON)"
    Else
        cmdKey(1).Caption = "SHIFT (OFF)"
    End If
Else
    If boShift = True Then
        intASC = Index
    Else
        intASC = Index + (Asc("a") - Asc("A"))
    End If
    If Index = 32 Then intASC = Index
    strInput = Chr(intASC)
    Text1.Text = Text1.Text & strInput
End If
End Sub

Private Sub Form_Load()
Dim intI As Integer
cmdKey(0).Left = 240
cmdKey(0).Top = 360
cmdKey(0).Width = 495
cmdKey(0).Height = 375
Me.Width = (26 * (cmdKey(0).Width + 50)) + (2 * cmdKey(0).Left)
For intI = Asc("A") To Asc("Z")
    Load cmdKey(intI)
    cmdKey(intI).Caption = Chr(intI)
    If intI = 65 Then
        cmdKey(intI).Left = 240
        cmdKey(intI).Top = 360
    Else
        cmdKey(intI).Left = cmdKey(intI - 1).Left + cmdKey(intI - 1).Width + 50
        cmdKey(intI).Top = cmdKey(intI - 1).Top
    End If
    cmdKey(intI).Visible = True
Next intI
'
' Space Bar
'
Load cmdKey(32)
cmdKey(32).Caption = "Space"
cmdKey(32).Top = cmdKey(0).Top + cmdKey(0).Height + 50
cmdKey(32).Width = 6375
cmdKey(32).Visible = True
cmdKey(32).Left = (Me.Width / 2) - (cmdKey(32).Width / 2)
'
' Shift Key
'
Load cmdKey(1)
cmdKey(1).Caption = "SHIFT (OFF)"
cmdKey(1).Top = cmdKey(0).Top + cmdKey(0).Height + 50
cmdKey(1).Left = cmdKey(0).Left
cmdKey(1).Width = 1455
cmdKey(1).Visible = True
End Sub