本文整理汇总了PHP中Functions类的典型用法代码示例。如果您正苦于以下问题:PHP Functions类的具体用法?PHP Functions怎么用?PHP Functions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Functions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process($parentRule)
{
static $thisFunction;
if (!$thisFunction) {
$thisFunction = new Functions(array('this' => 'CssCrush\\fn__this'));
}
if (!$this->skip) {
// this() function needs to be called exclusively because it is self referencing.
$context = (object) array('rule' => $parentRule);
$this->value = $thisFunction->apply($this->value, $context);
if (isset($parentRule->declarations->data)) {
$parentRule->declarations->data += array($this->property => $this->value);
}
$context = (object) array('rule' => $parentRule, 'property' => $this->property);
$this->value = Crush::$process->functions->apply($this->value, $context);
}
// Whitespace may have been introduced by functions.
$this->value = trim($this->value);
if ($this->value === '') {
$this->valid = false;
return;
}
$parentRule->declarations->queryData[$this->property] = $this->value;
$this->indexFunctions();
}
示例2: __construct
public function __construct($str)
{
static $templateFunctions;
if (!$templateFunctions) {
$templateFunctions = new Functions();
}
$str = Template::unTokenize($str);
// Parse all arg function calls in the passed string,
// callback creates default values.
$self = $this;
$captureCallback = function ($str) use(&$self) {
$args = Functions::parseArgsSimple($str);
$position = array_shift($args);
// Match the argument index integer.
if (!isset($position) || !ctype_digit($position)) {
return '';
}
// Store the default value.
$defaultValue = isset($args[0]) ? $args[0] : null;
if (isset($defaultValue)) {
$self->defaults[$position] = $defaultValue;
}
// Update argument count.
$argNumber = (int) $position + 1;
$self->argCount = max($self->argCount, $argNumber);
return "?a{$position}?";
};
$templateFunctions->register['#'] = $captureCallback;
$templateFunctions->register['arg'] = $captureCallback;
$this->string = $templateFunctions->apply($str);
}
示例3: write_div_table_display_records
function write_div_table_display_records($order = null, $order_type = null)
{
$data['stocks'] = $this->Stocks_model->get_all_display($order, $order_type);
$functions = new Functions();
$link_to_screen = base_url() . 'inventory/stocks';
return $functions->display_data_table($data['stocks'], $link_to_screen, $this);
}
示例4: actionGetAddress
public function actionGetAddress()
{
$value = $_POST['val'];
$function = new Functions();
$address = $function->getAddress($value);
$this->renderPartial('getAddress', array('address' => $address));
}
示例5: do_update
function do_update()
{
$Q[] = "ALTER TABLE exp_members ADD `ignore_list` text not null AFTER `sig_img_height`";
/*
* ------------------------------------------------------
* Add Edit Date and Attempt to Intelligently Set Values
* ------------------------------------------------------
*/
require PATH_CORE.'core.localize'.EXT;
$LOC = new Localize();
$Q[] = "ALTER TABLE exp_templates ADD `edit_date` int(10) default 0 AFTER `template_notes`";
$Q[] = "UPDATE exp_templates SET edit_date = '".$LOC->now."'";
$query = $this->EE->db->query("SELECT item_id, MAX(item_date) as max_date FROM `exp_revision_tracker` GROUP BY item_id");
if ($query->num_rows() > 0)
{
foreach($query->result_array() as $row)
{
$Q[] = "UPDATE exp_templates SET edit_date = '".$DB->escape_str($row['max_date'])."' WHERE template_id = '".$DB->escape_str($row['item_id'])."'";
}
}
/*
* ------------------------------------------------------
* Add Hash for Bulletins and Set For Existing Bulletins
* ------------------------------------------------------
*/
$Q[] = "ALTER TABLE `exp_member_bulletin_board` ADD `hash` varchar(10) default '' AFTER `bulletin_date`";
$Q[] = "ALTER TABLE `exp_member_bulletin_board` ADD INDEX (`hash`)";
$query = $this->EE->db->query("SELECT DISTINCT bulletin_date, bulletin_message, sender_id FROM `exp_member_bulletin_board`");
if ($query->num_rows() > 0)
{
require PATH_CORE.'core.functions'.EXT;
$FNS = new Functions();
foreach($query->result_array() as $row)
{
$Q[] = "UPDATE exp_member_bulletin_board SET hash = '".$DB->escape_str($FNS->random('alpha', 10))."'
WHERE bulletin_date = '".$DB->escape_str($row['bulletin_date'])."'
AND bulletin_message = '".$DB->escape_str($row['bulletin_message'])."'
AND sender_id = '".$DB->escape_str($row['sender_id'])."'";
}
}
// run the queries
foreach ($Q as $sql)
{
$this->EE->db->query($sql);
}
return TRUE;
}
示例6: actionAddAddr
public function actionAddAddr()
{
$func = new Functions();
if (isset($_POST['addresses'])) {
foreach ($_POST['addresses'] as $key => $val) {
$id = $func->createReestr($val, $_POST['id']);
$model[$key] = Yii::app()->db->createCommand()->select()->from('reestrAddr r')->join('addresses adr', 'adr.addressesID = r.addressId')->where('r.reestrAddrId = :id', array(':id' => $id))->queryRow();
}
}
$this->renderPartial('partial/addAddr', array('model' => $model));
}
示例7: genPls
public function genPls()
{
$read = new Functions();
$channel = $read->openFile();
foreach ($channel as $key => $value) {
$read->getServerInfo($value);
$name = $read->name;
$this->genRam($read->chan, $read->ip, $read->port);
$this->genAsx($read->chan, $read->ip, $read->port);
$this->genM3u($read->chan, $read->ip, $read->port, $name);
}
echo 'Generowanie plikow playlist zakonczone sukcesem.';
}
示例8: expandAliases
public static function expandAliases($str)
{
$process = Crush::$process;
if (!$process->selectorAliases || !preg_match($process->selectorAliasesPatt, $str)) {
return $str;
}
while (preg_match_all($process->selectorAliasesPatt, $str, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
$alias_call = end($m);
$alias_name = strtolower($alias_call[1][0]);
$start = $alias_call[0][1];
$length = strlen($alias_call[0][0]);
$args = array();
// It's a function alias if a start paren is matched.
if (isset($alias_call[2])) {
// Parse argument list.
if (preg_match(Regex::$patt->parens, $str, $parens, PREG_OFFSET_CAPTURE, $start)) {
$args = Functions::parseArgs($parens[2][0]);
// Amend offsets.
$paren_start = $parens[0][1];
$paren_len = strlen($parens[0][0]);
$length = $paren_start + $paren_len - $start;
}
}
$str = substr_replace($str, $process->selectorAliases[$alias_name]($args), $start, $length);
}
return $str;
}
示例9: amchroot_edit
function amchroot_edit($domain, $mode)
{
$cmd = "amh module AMChroot-1.1 admin edit,{$domain},{$mode}";
$cmd = Functions::trim_cmd($cmd);
exec($cmd, $tmp, $status);
return !$status;
}
示例10: module_delete
function module_delete($name)
{
$cmd = "amh module {$name} delete y";
$cmd = Functions::trim_cmd($cmd);
exec($cmd, $tmp, $status);
return !$status;
}
示例11: checkDate
public static function checkDate($date, $class)
{
//check if set and date null
//return error
if (!isset($class->date) && $date == null) {
//return error code and msg if there is no date set;
$error = Functions::error(100, "Date is not set");
} else {
if ($date == null) {
//set date from class
$date = $class->date;
}
}
//check if format is right
$date = date_create_from_format('d.m.Y', $date);
//if format is not correct
if ($date == false) {
$error = Functions::error(100, "Date is not in right format (d.m.Y)");
}
//get format back, no clock needed
$date = date_format($date, 'd.m.Y');
//return right date
//date in function getData('date') is more imporatant than set date in class
return $date;
}
示例12: discover
/**
* Discovers all the annotations of a given class file
*
* @param string $class a class file
* @return array
*/
public static function discover($class)
{
try {
if (!file_exists($class)) {
throw new Exception($class . " does not exist");
}
$text = file($class, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$annotations = array();
$currentAnnotations = array();
foreach ($text as $key => $line) {
if (strpos($line, "* @annotation") !== false) {
$currentAnnotations[] = trim(str_replace("* @annotation", "", $line));
} else {
$functionName = "";
if (count($currentAnnotations) > 0 && Annotation::discoverFunctionName($line, $functionName)) {
$annotations[$functionName] = $currentAnnotations;
$currentAnnotations = array();
}
unset($text[$key]);
}
}
return $annotations;
} catch (Exception $e) {
Functions::dump($e->getMessage());
return NULL;
}
}
示例13: get_metadata
public static function get_metadata($url)
{
$xml = Functions::lookup_with_cache($url, array('validation_regex' => 'xmlns:'));
$simple_xml = simplexml_load_string($xml);
$params = array();
$dcterms = $simple_xml->children("http://dublincore.org/documents/dcmi-terms/");
$dwc = $simple_xml->children("http://digir.net/schema/conceptual/darwin/2003/1.0");
$params['source'] = (string) $dcterms->identifier;
$data_object = $simple_xml->dataObject;
$dcterms = $data_object->children("http://dublincore.org/documents/dcmi-terms/");
$params['citation'] = (string) $dcterms->bibliographicCitation;
$params['identifier'] = (string) $dcterms->identifier;
$params['data_type'] = "http://purl.org/dc/dcmitype/Text";
$params['mime_type'] = "text/html";
$params['license'] = "not applicable";
$params['agents'] = array();
foreach ($data_object->agent as $agent) {
$agent_name = (string) $agent;
$attr = $agent->attributes();
$agent_role = (string) @$attr['role'];
$params['agents'][] = array($agent_name, $agent_role);
}
print_r($xml);
// print_r($params);
echo "\n\n\n";
}
示例14: init
public function init()
{
parent::init();
// Create new field in your users table for store dashboard preference
// Set table name, user ID field name, user preference field name
$this->setTableParams('dashboard_page', 'user_id', 'title');
// set array of portlets
$this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
//set content BEFORE dashboard
$this->setContentBefore();
// uncomment the following to apply jQuery UI theme
// from protected/components/assets/themes folder
$this->applyTheme('ui-lightness');
// uncomment the following to change columns count
//$this->setColumns(4);
// uncomment the following to enable autosave
$this->setAutosave(true);
// uncomment the following to disable dashboard header
$this->setShowHeaders(false);
// uncomment the following to enable context menu and add needed items
/*
$this->menu = array(
array('label' => 'Index', 'url' => array('index')),
);
*/
}
示例15: loop_resolve_list
function loop_resolve_list($list_text)
{
// Resolve the list of items for iteration.
// Either a generator function or a plain list.
$items = array();
$list_text = Crush::$process->functions->apply($list_text);
$generator_func_patt = Regex::make('~(?<func>range|color-range) {{parens}}~ix');
if (preg_match($generator_func_patt, $list_text, $m)) {
$func = strtolower($m['func']);
$args = Functions::parseArgs($m['parens_content']);
switch ($func) {
case 'range':
$items = call_user_func_array('range', $args);
break;
default:
$func = str_replace('-', '_', $func);
if (function_exists("CssCrush\\loop_{$func}")) {
$items = call_user_func_array("CssCrush\\loop_{$func}", $args);
}
}
} else {
$items = Util::splitDelimList($list_text);
}
return $items;
}