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");
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.
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”); |
Executes a query query_name. Returns the result set as a data set.
Executes SQL query. Returns array.
Simple query, will return all records from table 'letters':
$data = $yc->executeSQL( "SELECT * FROM letters" ); |
This example will return 10 records from table 'letters' ordered by 'title' column:
$data = $yc->executeSQL( "SELECT * FROM letters ORDER BY title LIMIT 10" ); |
Deprecated. Use getRecords() instead.
Returns records from the dataset of type type named name. Type can be the following:
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.
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 ); |
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” ); |
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.
This function is used to retrieve session variable var.
$value = $yc->get( “auth” ); |
See also:
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.
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:
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.
Removes variable var from PHP session.
See also:
Returns array:
array(' content' => $content, 'headers' => $headers );
Use this function to return content in onBeforeLoad actions.
Deprecated.
Not implemented.
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.
Deletes chat sessions. Session ID is used as the bind argument. In case of successful execution returns TRUE.
Returns the list of chat sessions.
Returns the settings of a payment system using identifier ident. Usually used in combination with functions googleTransaction or paypalTransaction.
Returns customer's data using e-mail address and password.
Returns the list of orders using customer's identifier customerId.
Returns complete information about the order using identifier id.
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
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].'"'); } |
Returns content of the file by its 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
Returns list of images by folder ID or path. Example output described in function getFileInfo.
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] =>
Returns module object by type. Account argument is not used. Allowed types are:
YC_IMAGE
YC_FILE
YC_SOLUTION
Returns information about YC object (file, image, solution) by path. Example output described in getFileInfo. Allowed types are:
YC_IMAGE
YC_FILE
YC_SOLUTION
Deprecated. Use getObject instead.
Returns objects list by path and type. For additional information see getObject and getFileInfo.
Returns structured tags with count data. Used in "Tags & Clouds" gear.
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
Returns javascript wrapper for SWFObject. Can be used to add SWF object to the web page.
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 ); |
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
)
)
)
Removes a file with ID = id from account. Returns exception on failure or nothing on success.
$yc->deleteFileById( 123 ); |
Removes a file from account by its path. Returns exception on failure or nothing on success.
$yc->deleteFileByPathName( "/myFolder/myFile.txt" ); |
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;
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" ); |
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]; |
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
)
)
)
Upload SolutionFile into account. SolutionName is the name of the imported solution.
$solution = $arguments['_FILES']['solution_upload'][0]; |
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
)
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] ); |
Uploads image into account. This function has same behavior as uploadFile, except it doesn't have readonly argument.
This function is designed to be used in system actions (gears).
This function is designed to be used in system actions (gears).
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
// iframe with scrolling |