Introduction

Account

Web System Common Tools

Web System Applications Development

 Web System Database Web System PostgreSQL Tables Web System Manage fields Web System Manage constraints Web System Manage indexes Web System Manage triggers Web System SQL Tab Web System Single-row editing Web System Multirow editing in table mode Web System Import Web System Export Web System Table transfer - or Store Web System Composite Types Web System SQL Queries Web System Workflow Web System Dataset Design Web System Query Expressions Web System Where Conditions Web System Group by Expressions Web System Having Condition Web System Windows Clause Web System Order by Expressions Web System SQL Tab Web System Test a Query Web System Views Web System Functions Web System Datasources Web System Charts Web System Main type selection Web System Subtype selection Web System Datasource selection Web System General settings Web System Axis settings Web System Background settings Web System Margin settings Web System Color settings Web System Mark settings Web System QR Barcodes Web System Saving Web System Reports Web System Template Editor GYRE Web System Sections Web System Toolbar Web System Basic properties Web System Data formatting Web System Text Web System Data Web System Macro Web System Geometry Web System Line Web System Bezier curve Web System Image Web System Chart Web System Arrangement Web System Clipboard Web System History Web System Zoom Web System Import/export Web System Delete Web System Report Generator Web System Report Schedule Web Site Builder Web System Content Management System (CMS) Web System Edit site Web System Themes and pages Web System Create and edit theme Web System Edit page Web System Web Form Builder / Content Editor (GYRE) Web System Toolbar Web System Events Web System Basic properties Web System Text field Web System Button Web System List Web System Combobox Web System Label Web System Checkbox Web System Radiobutton Web System Filler Web System Upload file Web System Additional tools (Gears) Web System Image Web System Flash video Web System Arrangement Web System Clipboard Web System History Web System Zoom Web System Import/export Web System Delete Web System Operations with objects Web System DNS Manager Web System SEO tools Web System App Analyzer Web System Reindex Web System Publish Web System Access Log Web System Checkout settings Web System PHP Scripts development (Actions) Web System Source Editor Web System API functions Web System Custom Scripts development (JS, CSS, XML, etc...) Web System Gears Web System SaaS Solution Manager

Web System Cook book

Web System Deprecated

Web System API functions

API (Application Programming Interface) is  a set of ready-made functions provided by Younicycle for writing custom scripts. All API-functions are global class methods $yc API-function execution example:

$records = $yc->getRecordsFromTable("myTable");

 



  • clearTable( table_name , [ reset_sequences ] )

Deletes all information from a table table_name. To reset the sequence (autoincrement), second argument must return TRUE. In case of successful execution returns TRUE, otherwise - FALSE.

  • deleteRecordsFromTable( table_name , key_name , key_value )

Deletes all entries from a table  table_name, using key_name = key_value filter. In case of successful execution returns TRUE, otherwise - FALSE or an error message.

Example. Delete all entries from the table orders, where the field order_date is “2010-02-27”:

$yc->deleteRecordsFromTable(“orders”, “order_date”, “2010-02-27”);

  • executeQuery( query_name , [ prompt_params ] )

Executes a query  query_name. Returns the result set as a data set.

  • executeSQL( sql )

Executes SQL query. Returns array.

Simple query, will return all records from table 'letters':

$data = $yc->executeSQL( "SELECT * FROM letters" );
foreach($data as $record)
{
  echo $record['title']."<br>";
}


This example will return 10 records from table 'letters' ordered by 'title' column:

$data = $yc->executeSQL( "SELECT * FROM letters ORDER BY title LIMIT 10" );
foreach($data as $record)
{
  echo $record['title']."<br>";
}

Deprecated. Use getRecords() instead.

  • getRecords(  type , name , [ filters ] , [ prompt_params ] , [ pagesize ] , [ pagenr ] , [ order ] )

Returns records from the dataset of type type named name. Type can be the following:

  • YC_TABLE
  • YC_QUERY
  • YC_DATASOURCE

If a filter is not defined, the function returns all records from the dataset. The filter can be an array or string:

$filter = array(“id”=>”768”);

$filter = “id=768”;

promt_params: array( [param_name] => [value] ) can be null

pagesize: number can be null

pagenr: number can be null

order: array ( " [field name] [asc / desc] " ) can be null

Examle:

For geting all rows from table "myTable" with order name by asc needed

$data = $yc->getRecords( YC_TABLE, "myTable", null, null, null, null, array(" name asc") );

  

Deprecated. Use getRecords() instead.

Deprecated. Use getRecords() instead.

  • insertIntoTable( table_name , hash )

Inserts a hash record into a table table_name. hash argument is a "field" = "value" type array. Example:

$hash = array(“name”=>”Pencil”, “price”=>”10.99”, “description”=>”A pencil is a writing implement.”);

$yc->insertIntoTable( “products” , $hash );

  • updateRecordsInTable( table_name , hash , key_name , key_value )

Updates (changes) records in the specified columns of a table table_name using filter. The updated values are passed as hash arguments. hash argument is a "field" = "value" type array. Filter is created using key_name / key_value arguments

Example: Update “products” table, with the field values “price”=”10.99”, where the field “name” = “Pencil”.

$hash = array(“price”=>”10.99”);

$yc->updateRecordsInTable( “products” , $hash , “name” , “Pencil” );

  • checkUserInAccount( login , password )

Searches for a user login and password within the current account. In case of successful execution returns the user ID, otherwise - FALSE. All arguments are mandatory.

  • get( var )

This function is used to retrieve session variable var.

$value = $yc->get( “auth” );

See also:

  • set
  • remove

Note: A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application. PHP session allows you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database.

  • set( var, value )

This function is used to store value into session variable var. This value can be retrieved by calling $yc->get() with variable name as argument.

$yc->set( “auth”, “100” );

See also:

  • get
  • remove

Note: A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application. PHP session allows you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database.

  • remove( var )

Removes variable var from PHP session.

See also:

  • set
  • get
  • content( content , [ headers ] )

Returns array:

array(' content' => $content, 'headers' => $headers );

Use this function to return content in onBeforeLoad actions.

Deprecated.

Not implemented.

  • createThumbnail( image_id , thumb_name , thumb_size , [ foldid ] , [ description ] , [ public ] )

Creates thumbnailed image inside YC Images section.

image_id - is the parent image ID

thumb_name - is the name of thumbnailed image

thumb_size - is the widest side of the thumbnailed image

foldid - is the folder ID (where to put thumbnailed image)

description - is the description of thumbnailed image

public - set to TRUE if you want thumbnailed image to be public

Returns ID of created thumbnail or FALSE on failure.

  • deleteChatSession( session_id )

Deletes chat sessions. Session ID is used as the bind argument. In case of successful execution returns TRUE.

  • getChatSessions( )

Returns the list of chat sessions.

  • getCheckoutSettings( ident )

Returns the settings of a payment system using identifier ident. Usually used in combination with functions googleTransaction or paypalTransaction.

  • getCustomer( email , password )

Returns customer's data using e-mail address and password.

  • getCustomerOrders( customerId )

Returns the list of orders using customer's identifier customerId.

  • getOrder( id )

Returns complete information about the order using  identifier id.

  • getOrders( [ filter ] , [ sort ] )

Returns the list of orders using filter filter. Also rules for sorting the list of orders can be used, through the return of argument sort. Filter is an associative array:

 

$filter[] = “date_create < '2010-01-17'”;

$filter[] = “status >= 0”;

Filter elements are combined with a logical "AND". Thus the conditions of sample size in the resulting query would be:

WHERE date_create < '2010-01-17' AND status >= 0”

Argument sort also must be an array:

$sort = array(“field”, “sorting_rule”)

Where field is a column by which the list will be sorted, and the "sorting rule" is one of two values:

ASC –ascending sort

DESC –descending sort

  • googleTransaction( checkout_config , cart )
  • paypalTransaction( checkout_config , cart )

Initiates a transaction in one of the payment systems - Google Checkout or Paypal Express checkout. The first argument is  payment system adjustments (see function getCheckoutSettings). Argument cart (shopping cart)  is an array:

$cartItem['id'] – product ID

$cartItem['name'] – product name

$cartItem['description'] –product description

$cartItem['quantity'] – product quantity

$cartItem['price'] – product price

$cart[] = $cartItem;

If successful, the function returns the code and address of the payment system for forwarding. Example:

$checkout_settings = $yc->getCheckoutSettings( 'google_sandbox' );

$info = $yc->googleTransaction( $checkout_settings, $cart );

if (($info[0] == 200 || stristr($info[0], 'success')) && !empty($info[1]))

{

$response->addScript('window.location.href = "'.$info[1].'"');

}

  • getFileData( path )

Returns content of the file by its path.

  • getFileInfo( path )

Returns information about file by its path.

$fileInfo = $yc->getFileInfo( 'myFolder/style.css' );

Example output:

[id] => 4794
[name] => style.css
[description] => Styles for my site
[date_create] => 2009-11-23 09:09:06.267815
[date_modify] => 2011-08-29 05:44:22.712257
[date_access] => 2011-08-29 05:44:22.712257
[owner] => 1
[group] =>
[foldid] => 119
[public] => t
[readonly] => f
[deleted] => 0
[metadata] =>
[size] => 161
[type] => text/css
[path] => 1/11/
[folder_path] => /myFolder
[url] => /files/test/myFolder/style.css
[directlink] => http://www.younicycle.com/files/test/myFolder/style.css
[streamlink] => http://www.younicycle.com/filestream/test/myFolder/style.css

  • getImagesFromFolder( foldid_or_path )

Returns list of images by folder ID or path. Example output described in function getFileInfo.

  • getLoggedUser( )

Returns information about user who currently logged in system.

Example output:

[uid] => 1
[ulogin] => john
[upassword] => 05a671c66aefea124cc08b76ea6d30bb
[ufname] => John
[umname] =>
[ulname] => Smith
[uemail] => user@test.com
[uphone] =>
[uorganization] =>
[udepartment] =>
[ulanguage] => en
[ussl_cert] =>
[uregdate] => 2006-05-13 02:35:57.072362
[uallow_network] =>
[is_admin] => t
[is_multisession] => t
[is_enabled] => t
[gmail_address] =>
[gmail_customer_key] =>
[gmail_customer_secret] =>
[gmail_tokens_cache] =>
[gmail_secret_word] =>
[gmail_last_check] =>
[gmail_folders] =>
[gmail_schedule_id] =>

  • getModuleByType( type , [ account ] )

Returns module object by type. Account argument is not used. Allowed types are:

YC_IMAGE
YC_FILE
YC_SOLUTION

  • getObject( path , type )

Returns information about YC object (file, image, solution) by path. Example output described in getFileInfo. Allowed types are:

YC_IMAGE
YC_FILE
YC_SOLUTION

  • getObjectInfo( path , type )

Deprecated. Use getObject instead.

  • getObjectsFromFolder( path , type )

Returns objects list by path and type. For additional information see getObject and getFileInfo.

  • getPagesTags( )

Returns structured tags with count data. Used in "Tags & Clouds" gear.

  • getRootPath( type )

Returns a part of root path to the object, depending on type argument. Account name is automatically attached. This part of path can be used to form public link to object. Allowed types are:

YC_IMAGE
YC_FILE
YC_SITE
YC_REPORT

$rootPath = $yc->getRootPath( YC_FILE );

The above example will output:

files/current_account

$rootPath = $yc->getRootPath( YC_IMAGE );

Output:

imgs/current_account

$rootPath = $yc->getRootPath( YC_SITE );

Output:

web/current_account

$rootPath = $yc->getRootPath( YC_REPORT );

Output:

reports/current_account

  • getSWFObject( swfpath , obj )

Returns javascript wrapper for SWFObject. Can be used to add SWF object to the web page.

  • sendPostData( server , url , data )

Makes a POST request to the server and url. It will return server response on success, FALSE on failure.

$response = $yc->sendPostData( 'http://www.test.com', 'form/proceed', $data );

  • TransposeData( data , keys , [ columns, ] [ keySeparator, ] [ addKey ] )

Transposing, in simple terms, is to interchange rows and columns of a matrix (two-dimensional array).

 

$data = array(
          array('station_id' => "Station 1",
            'month' => "Jan",
            'average_temp' => "25.65"
                ),
        array('station_id' => "Station 1",
            'month' => "Feb",
            'average_temp' => "27.72"
                ),
        array('station_id' => "Station 1",
            'month' => "Mar",
            'average_temp' => "37.03"
                )
);

$columns = array('average_temp');
$result = $yc->TransposeData($data, "month", $columns);

The above example will output:

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [Jan] => 25.65
                    [Feb] => 27.72
                    [Mar] => 37.03
                )
        )

    [structure] => Array
        (
            [row_count] => 1
            [field_count] => 3
            [field_type] => Array
                (
                    [Jan] => text
                    [Feb] => text
                    [Mar] => text
                )
        )
)

  • deleteFileById( id )

Removes a file with ID = id from account. Returns exception on failure or nothing on success.

$yc->deleteFileById( 123 );

  • deleteFileByPathName( path )

Removes a file from account by its path. Returns exception on failure or nothing on success.

$yc->deleteFileByPathName( "/myFolder/myFile.txt" );

  • getFileContentType( file_path )

Returns content type (mime-type) property of the file.

Note: file_path must be the full path to the file.

$yc->getFileContentType( "/tmp/message.log" );

The above example will output:

text/plain;

  • redirect( redirect_url )

Send a raw HTTP header Location. It does send this header back to the browser, and it also returns a REDIRECT (302) status code to the browser.

Note: This function will not work if action called using xAjax (for example from the GYRE). Use onBeforeLoad actions instead.

$yc->redirect( "http://www.google.com" );

  • getSolutionInfo( SolutionFile )

Returns full solution info by package file name. The output contans information about all solution objects, version, author, etc. SolutionFile must be full path to the file. Can be used when uploading solution files.

 

$solution = $arguments['_FILES']['solution_upload'][0];
$solution = explode(':', $solution);
$info = $yc->getSolutionInfo($solution[1]);

The above example will output:

[objects] => Array
(
  [Images] => Array
  (
   [0] => Array
   (
    [id] => 4242
    [name] => bgheader.jpg
    [folder_path] => /myfolder
    [ismissing] => 0
    [old_id] => 7
   )

   [1] => Array
   (
    [id] => 6700
    [name] => header.png
    [folder_path] => /myfolder
    [ismissing] => 0
    [old_id] => 21
   )
  )
  [Files] => Array
  (
   [0] => Array
   (
    [id] => 6701
    [name] => style.css
    [folder_path] => /myfolder
    [ismissing] => 0
    [old_id] => 46
   )

   [1] => Array
   (
    [id] => 6702
    [name] => menu.js
    [folder_path] => /myfolder
    [ismissing] => 0
    [old_id] => 61
   )
  )
  [Actions] => Array
  (
   [0] => Array
   (
    [id] => 6703
    [name] => contactUs
    [folder_path] =>.
    [ismissing] => 0
    [old_id] => 64
   )
  )
 )
[info] => Array
(
 [name] => mysolution
 [description] =>.
 [date_create] => 2011-05-10 11:04:50
 [author] => test
 [version] => 1.0
 [ycversion] =>.
 [public] => f
 [foldid] => 1
 [run_command] =>.
 [size] => 626232
)

[requirements] => Array
(
 [0] => Array
 (
  [reqtext] => Requires PDFLIB license
  [ismandatory] => 0
  [accepted] => No
 )
 [1] => Array
 (
  [reqtext] => I am the Solution Owner
  [ismandatory] => 0
  [accepted] => Yes
 )
 [2] => Array
 (
  [reqtext] => I am the Solution Developer
  [ismandatory] => 0
  [accepted] => No
 )
)
)

  • uploadSolutionFileInAccount( SolutionFile, SolutionName )

Upload SolutionFile into account. SolutionName is the name of the imported solution.

 

$solution = $arguments['_FILES']['solution_upload'][0];
$solution = explode(':', $solution);
$info = $yc->uploadSolutionFileInAccount($solution[1], $solution[0]);

  • getSolutionList()

Returns solutions list.

 

$solution_list = $yc->getSolutionList();

The above example will output:

[0] => Array
(
    [id] => 6659
    [name] => mySolution
    [description] =>
    [date_create] => 2011-05-10 11:33:01.214077
    [date_modify] => 2011-05-10 11:33:02.309172
    [date_access] => 2011-05-10 11:33:02.309172
    [foldid] => 1
    [owner] => 1
    [public] => f
    [deleted] => 0
    [metadata] =>
    [version] => 1.0
    [ycversion] =>
    [author] => test
    [size] => 626232
    [packagename] => mysolution.0.yc3
    [run_command] =>
    [details] => {}
    [foldname] => Root
    [status] => OK
    [installid] => 17
)

[1] => Array
(
    [id] => 5263
    [name] => newSolution
    [description] =>
    [date_create] => 2010-05-28 03:23:27.11476
    [date_modify] => 2010-05-28 03:23:27.11476
    [date_access] => 2010-05-28 03:23:27.11476
    [foldid] => 48
    [owner] => 1
    [public] => f
    [deleted] => 0
    [metadata] =>
    [version] => 2.0
    [ycversion] => 3.0
    [author] => test
    [size] => 10956100
    [packagename] => newsolution.0.yc3
    [run_command] =>
    [details] => {}
    [foldname] => myFolder
    [status] => Not istalled
)

  • uploadFile( name , file_path , folder_path , [ description ] , [ public ] , [ readonly ] )

Uploads file into account.

name - is the name for uploaded file. Can be taken from $arguments['_FILES']

file_path - real path where the uploaded file placed. Must be taken from $arguments['_FILES']

folder_path - younicycle path

description - optional description for uploaded file

public - set to TRUE if you want uploaded file to be public, default is FALSE

readonly - set to TRUE if you want uploaded file to be readonly, default is FALSE

 

$file = explode( ':', $arguments['_FILES']['upload_file'][0] );
$file_name = 'myfile';
$file_path = $file[1];
$folder_path = '/myfolder';

if ( $yc->uploadFile( $file_name , $file_path , $folder_path , '', true) )
{
    $response->alert('Upload success');.
}
else
{
    $response->alert('Upload error');.
}

  • uploadImage( name , file_path , folder_path , [ description ] , [ public ] )

Uploads image into account. This function has same behavior as uploadFile, except it doesn't have readonly argument.

  • search( q , offset , limit , [ searchArea ] )

This function is designed to be used in system actions (gears).

  • renderTemplate( [ gear ] , [ template ] , [ params ] )

This function is designed to be used in system actions (gears).

  • iframe( src , [ iframeId ] , [ width ] , [ height ] , [ scrolling ] )

This function returns HTML iframe tag. The iframe tag defines an inline frame that contains another document.

src - Specifies the URL of the document to show in an iframe

iframeId - Specifies a unique id for an element

width - Specifies the width of an iframe. Default is 100%

height - Specifies the height of an iframe. Default is 100%

scrolling - Specifies whether or not to display scrollbars in an iframe. Possible values: "yes", "no", "auto". Default is "no".

Usage:

// simple iframe
return $yc->iframe("http://www.younicycle.com/index.html");

// iframe dimensions
// Note: width and height can be in pixels or in percentages
return $yc->iframe("http://www.younicycle.com/index.html", null, "200", "300");
// or
return $yc->iframe("http://www.younicycle.com/index.html", null, "100%", "100%");

// iframe with scrolling
return $yc->iframe("http://www.younicycle.com/index.html", null, null, null, "yes");
// or
return $yc->iframe("http://www.younicycle.com/index.html", null, "100%", "100%", "auto");