当前位置: 首页>>代码示例>>PHP>>正文


PHP General::createHandle方法代码示例

本文整理汇总了PHP中General::createHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP General::createHandle方法的具体用法?PHP General::createHandle怎么用?PHP General::createHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在General的用法示例。


在下文中一共展示了General::createHandle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildEditor

 public static function buildEditor(XMLElement $wrapper, array &$errors = array(), array $settings = null, $handle = null)
 {
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/section_schemas/assets/section_schemas.datasource.js', 100);
     if (is_null($settings[self::getClass()]['fields'])) {
         $settings[self::getClass()]['fields'] = array();
     }
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings contextual ' . __CLASS__);
     $fieldset->setAttribute('data-context', General::createHandle(self::getName()));
     $fieldset->appendChild(new XMLElement('legend', self::getName()));
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $options = array();
     $sections = SectionManager::fetch();
     foreach ($sections as $section) {
         $options[] = array($section->get('handle'), $settings[self::getClass()]['section'] == $section->get('handle'), $section->get('name'));
     }
     $label = Widget::Label(__('Section'));
     $label->setAttribute('class', 'column');
     $label->appendChild(Widget::Select('fields[' . self::getClass() . '][section]', $options));
     $group->appendChild($label);
     foreach ($sections as $section) {
         $fields = $section->fetchFields();
         $options = array();
         foreach ($fields as $field) {
             $options[] = array($field->get('element_name'), in_array($field->get('element_name'), $settings[self::getClass()]['fields']), $field->get('label') . ' (' . $field->get('type') . ')');
         }
         $label = Widget::Label(__('Fields'));
         $label->setAttribute('class', 'column fields fields-for-' . $section->get('handle'));
         $label->appendChild(Widget::Select('fields[' . self::getClass() . '][fields][]', $options, array('multiple' => 'multiple')));
         $group->appendChild($label);
     }
     $fieldset->appendChild($group);
     $wrapper->appendChild($fieldset);
 }
开发者ID:symphonists,项目名称:section_schemas,代码行数:35,代码来源:datasource.section_schema.php

示例2: prepareExportValue

 /**
  * Give the field some data and ask it to return a value using one of many
  * possible modes.
  *
  * @param mixed $data
  * @param integer $mode
  * @param integer $entry_id
  * @return string|null
  */
 public function prepareExportValue($data, $mode, $entry_id = null)
 {
     $modes = (object) $this->getExportModes();
     // Export handles:
     if ($mode === $modes->getHandle) {
         if (isset($data['handle'])) {
             return $data['handle'];
         } else {
             if (isset($data['value'])) {
                 return General::createHandle($data['value']);
             }
         }
     } else {
         if ($mode === $modes->getUnformatted || $mode === $modes->getPostdata) {
             return isset($data['value']) ? $data['value'] : null;
         } else {
             if ($mode === $modes->getFormatted) {
                 if (isset($data['value_formatted'])) {
                     return $data['value_formatted'];
                 } else {
                     if (isset($data['value'])) {
                         return General::sanitize($data['value']);
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:38,代码来源:field.textbox.php

示例3: createHandle

 /**
  * Given a string, this will clean it for use as a Symphony handle. Preserves multi-byte characters.
  *
  * @param string $string
  *	String to be cleaned up
  * @param int $max_length
  *	The maximum number of characters in the handle
  * @param string $delim
  *	All non-valid characters will be replaced with this
  * @param boolean $uriencode
  *	Force the resultant string to be uri encoded making it safe for URLs
  * @param boolean $apply_transliteration
  *	If true, this will run the string through an array of substitution characters
  * @param array $additional_rule_set
  *	An array of REGEX patterns that should be applied to the `$string`. This
  *	occurs after the string has been trimmed and joined with the `$delim`
  * @return string
  *	Returns resultant handle
  */
 public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $apply_transliteration = true, $additional_rule_set = NULL)
 {
     // Use the transliteration table if provided
     if ($apply_transliteration == true) {
         $string = _t($string);
     }
     return General::createHandle($string, $max_length, $delim, $uriencode, $additional_rule_set);
 }
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:27,代码来源:class.lang.php

示例4: Drawer

 /**
  * Generates a XMLElement representation of a Symphony drawer widget.
  * A widget is identified by it's `$label`, and it's contents is defined
  * by the `XMLElement`, `$content`.
  *
  * @since Symphony 2.3
  * @param string $id
  *  The id attribute for this drawer
  * @param string $label
  *  A name for this drawer
  * @param XMLElement $content
  *  An XMLElement containing the HTML that should be contained inside
  *  the drawer.
  * @param string $default_state
  *  This parameter defines whether the drawer will be open or closed by
  *  default. It defaults to closed.
  * @param array $attributes (optional)
  *  Any additional attributes can be included in an associative array with
  *  the key being the name and the value being the value of the attribute.
  *  Attributes set from this array will override existing attributes
  *  set by previous params, except the `id` attribute.
  * @return XMLElement
  */
 public function Drawer($id = '', $label = '', XMLElement $content = null, $default_state = 'closed', $context = '', array $attributes = array())
 {
     $id = General::createHandle($id);
     $contents = new XMLElement('div', $content, array('class' => 'contents'));
     $contents->setElementStyle('html');
     $drawer = new XMLElement('div', $contents, $attributes);
     $drawer->setAttribute('data-default-state', $default_state);
     $drawer->setAttribute('data-context', $context);
     $drawer->setAttribute('data-label', $label);
     $drawer->addClass('drawer');
     $drawer->setAttribute('id', 'drawer-' . $id);
     return $drawer;
 }
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:36,代码来源:class.widget.php

示例5: __buildPage

    /**
     * This function sets the page's parameters, processes the Datasources and
     * Events and sets the `$xml` and `$xsl` variables. This functions resolves the `$page`
     * by calling the `resolvePage()` function. If a page is not found, it attempts
     * to locate the Symphony 404 page set in the backend otherwise it throws
     * the default Symphony 404 page. If the page is found, the page's XSL utility
     * is found, and the system parameters are set, including any URL parameters,
     * params from the Symphony cookies. Events and Datasources are executed and
     * any parameters  generated by them are appended to the existing parameters
     * before setting the Page's XML and XSL variables are set to the be the
     * generated XML (from the Datasources and Events) and the XSLT (from the
     * file attached to this Page)
     *
     * @uses FrontendPageResolved
     * @uses FrontendParamsResolve
     * @uses FrontendParamsPostResolve
     * @see resolvePage()
     */
    private function __buildPage()
    {
        $start = precision_timer();
        if (!($page = $this->resolvePage())) {
            throw new FrontendPageNotFoundException();
        }
        /**
         * Just after having resolved the page, but prior to any commencement of output creation
         * @delegate FrontendPageResolved
         * @param string $context
         * '/frontend/'
         * @param FrontendPage $page
         *  An instance of this class, passed by reference
         * @param array $page_data
         *  An associative array of page data, which is a combination from `tbl_pages` and
         *  the path of the page on the filesystem. Passed by reference
         */
        Symphony::ExtensionManager()->notifyMembers('FrontendPageResolved', '/frontend/', array('page' => &$this, 'page_data' => &$page));
        $this->_pageData = $page;
        $path = explode('/', $page['path']);
        $root_page = is_array($path) ? array_shift($path) : $path;
        $current_path = explode(dirname($_SERVER['SCRIPT_NAME']), $_SERVER['REQUEST_URI'], 2);
        $current_path = '/' . ltrim(end($current_path), '/');
        $split_path = explode('?', $current_path, 3);
        $current_path = rtrim(current($split_path), '/');
        $querystring = '?' . next($split_path);
        // Get max upload size from php and symphony config then choose the smallest
        $upload_size_php = ini_size_to_bytes(ini_get('upload_max_filesize'));
        $upload_size_sym = Symphony::Configuration()->get('max_upload_size', 'admin');
        $this->_param = array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => DateTimeObj::get('P'), 'website-name' => Symphony::Configuration()->get('sitename', 'general'), 'page-title' => $page['title'], 'root' => URL, 'workspace' => URL . '/workspace', 'root-page' => $root_page ? $root_page : $page['handle'], 'current-page' => $page['handle'], 'current-page-id' => $page['id'], 'current-path' => $current_path, 'parent-path' => '/' . $page['path'], 'current-query-string' => XMLElement::stripInvalidXMLCharacters(utf8_encode(urldecode($querystring))), 'current-url' => URL . $current_path, 'upload-limit' => min($upload_size_php, $upload_size_sym), 'symphony-version' => Symphony::Configuration()->get('version', 'symphony'));
        if (is_array($this->_env['url'])) {
            foreach ($this->_env['url'] as $key => $val) {
                $this->_param[$key] = $val;
            }
        }
        if (is_array($_GET) && !empty($_GET)) {
            foreach ($_GET as $key => $val) {
                if (in_array($key, array('symphony-page', 'debug', 'profile'))) {
                    continue;
                }
                // If the browser sends encoded entities for &, ie. a=1&b=2
                // this causes the $_GET to output they key as amp;b, which results in
                // $url-amp;b. This pattern will remove amp; allow the correct param
                // to be used, $url-b
                $key = preg_replace('/(^amp;|\\/)/', null, $key);
                // If the key gets replaced out then it will break the XML so prevent
                // the parameter being set.
                if (!General::createHandle($key)) {
                    continue;
                }
                $this->_param['url-' . $key] = XMLElement::stripInvalidXMLCharacters(utf8_encode(urldecode($val)));
            }
        }
        if (is_array($_COOKIE[__SYM_COOKIE_PREFIX_]) && !empty($_COOKIE[__SYM_COOKIE_PREFIX_])) {
            foreach ($_COOKIE[__SYM_COOKIE_PREFIX_] as $key => $val) {
                $this->_param['cookie-' . $key] = $val;
            }
        }
        // Flatten parameters:
        General::flattenArray($this->_param);
        /**
         * Just after having resolved the page params, but prior to any commencement of output creation
         * @delegate FrontendParamsResolve
         * @param string $context
         * '/frontend/'
         * @param array $params
         *  An associative array of this page's parameters
         */
        Symphony::ExtensionManager()->notifyMembers('FrontendParamsResolve', '/frontend/', array('params' => &$this->_param));
        $xml_build_start = precision_timer();
        $xml = new XMLElement('data');
        $xml->setIncludeHeader(true);
        $events = new XMLElement('events');
        $this->processEvents($page['events'], $events);
        $xml->appendChild($events);
        $this->_events_xml = clone $events;
        $this->processDatasources($page['data_sources'], $xml);
        Symphony::Profiler()->seed($xml_build_start);
        Symphony::Profiler()->sample('XML Built', PROFILE_LAP);
        if (is_array($this->_env['pool']) && !empty($this->_env['pool'])) {
            foreach ($this->_env['pool'] as $handle => $p) {
                if (!is_array($p)) {
//.........这里部分代码省略.........
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:101,代码来源:class.frontendpage.php

示例6: PaymentExecution

if (isset($_GET['success']) && $_GET['success'] == 'true') {
    $paymentId = $_GET['paymentId'];
    $payment = Payment::get($paymentId, $paypalExtension->getApiContext());
    $execution = new PaymentExecution();
    $execution->setPayerId($_GET['PayerID']);
    try {
        $result = $payment->execute($execution, $paypalExtension->getApiContext());
        try {
            $payment = Payment::get($paymentId, $paypalExtension->getApiContext());
            $state = $payment->getState();
            $transaction = current($payment->getTransactions());
            $invoiceID = $transaction->getInvoiceNumber();
            $invoice = current(EntryManager::fetch($invoiceID));
            $sectionID = $invoice->get('section_id');
            $fieldID = FieldManager::fetchFieldIDFromElementName('status', $sectionID);
            $invoice->setData($fieldID, array('value' => $state, 'handle' => General::createHandle($state)));
            $invoice->commit();
            $itemFieldID = FieldManager::fetchFieldIDFromElementName('item', $sectionID);
            if (in_array("JCI Malta Membership", $invoice->getData($itemFieldID)['description'])) {
                //user paid for a membership kindly convert user to a member
                $memberFieldID = FieldManager::fetchFieldIDFromElementName('member', $sectionID);
                $memberID = $invoice->getData($memberFieldID)['relation_id'];
                $member = current(EntryManager::fetch($memberID));
                $roleFieldID = FieldManager::fetchFieldIDFromElementName('role', $member->get('section_id'));
                $member->setData($roleFieldID, array('role_id' => 2));
                $member->commit();
                $emailID = FieldManager::fetchFieldIDFromElementName('email', $member->get('section_id'));
                $email = $member->getData($emailID)['value'];
                $member = ExtensionManager::getInstance('members')->getMemberDriver()->login(array('email' => $email));
            }
            header('Location: ' . URL . '/register/?thankyou=1', true, 302);
开发者ID:mazedigital,项目名称:paypal,代码行数:31,代码来源:content.payment.php

示例7: applyCKEditor

 /**
  * Load and apply CKEditor
  * @param $context
  * @return mixed
  */
 public function applyCKEditor($context)
 {
     /*          $format = $context['field']->get('text_formatter') == TRUE ? 'text_formatter' : 'formatter';
     
                 if(($context['field']->get($format) != 'ckeditor' && $context['field']->get($format) != 'ckeditor_compact')) return;*/
     if (!$this->addedCKEditorHeaders) {
         Administration::instance()->Page->addScriptToHead(URL . '/extensions/ckeditor/lib/ckeditor/ckeditor.js', 200, false);
         Administration::instance()->Page->addScriptToHead(URL . '/symphony/extension/ckeditor/js/', 209, false);
         Administration::instance()->Page->addScriptToHead(URL . '/extensions/ckeditor/assets/symphony.ckeditor.js', 210, false);
         Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/ckeditor/assets/symphony.ckeditor.css', 'screen', 30);
         $js = 'var ckeditor_presets = [];';
         $presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets`;');
         foreach ($presets as $preset) {
             $js .= 'ckeditor_presets.push({name:"' . $preset['name'] . '", class: "ckeditor_' . General::createHandle($preset['name'], 255, '_') . '", toolbar: [' . $preset['toolbar'] . '], plugins: "' . $preset['plugins'] . '", resize: ' . ($preset['resize'] == 1 ? 'true' : 'false') . ', outline: ' . ($preset['outline'] == 1 ? 'true' : 'false') . '});' . "\n";
         }
         $script = new XMLElement('script', $js, array('type' => 'text/javascript'));
         Administration::instance()->Page->addElementToHead($script);
         $this->addedCKEditorHeaders = true;
     }
 }
开发者ID:TwistedInteractive,项目名称:ckeditor,代码行数:25,代码来源:extension.driver.php

示例8: __importMultilanguage

 private function __importMultilanguage()
 {
     // Get the ID of the field which values should be imported:
     $fieldID = $_REQUEST['multilanguage-field-import'];
     // Get the nodes provided by this CSV file:
     $csv = new parseCSV();
     $csv->auto($_FILES['csv-file-ml']['tmp_name']);
     // Get the CSV Data:
     $csvData = $csv->data;
     // Get the languages:
     $supported_language_codes = $this->__getLanguages();
     // Itterate throught each row:
     $count = 0;
     foreach ($csvData as $row) {
         if (isset($row['entry_id'])) {
             $data = array();
             $first = true;
             // Itterate according to the languages that are available, not the ones that are defined in the CSV:
             foreach ($supported_language_codes as $code) {
                 // Check if this language code exists in the CSV data:
                 if (isset($row[$code])) {
                     // The first language in the CSV data is used as the default language:
                     if ($first) {
                         $data['handle'] = General::createHandle($row[$code]);
                         $data['value'] = General::sanitize($row[$code]);
                     }
                     // Store the value for this specific language:
                     $data['handle-' . $code] = General::createHandle($row[$code]);
                     $data['value-' . $code] = $row[$code];
                     $data['value_format-' . $code] = $row[$code];
                     $data['word_count-' . $code] = substr_count($row[$code], ' ') + 1;
                     $first = false;
                 }
             }
             // Update the data in the database:
             Symphony::Database()->update($data, 'tbl_entries_data_' . $fieldID, '`entry_id` = ' . trim($row['entry_id']));
             $count++;
         }
     }
     // Show the message that the import was successfull.
     $this->Form->appendChild(new XMLElement('p', __('Import successfull: ') . $count . ' ' . __('entries updated')));
     $p = new XMLElement('p');
     $p->appendChild(new XMLElement('a', __('Import another field'), array('href' => '?#multi')));
     $this->Form->appendChild($p);
 }
开发者ID:michael-e,项目名称:importcsv,代码行数:45,代码来源:content.index.php

示例9: processRowData

 public function processRowData(StdClass $settings, StdClass $data, $entry_id = null)
 {
     return (object) array('handle' => General::createHandle($data->{'title'}), 'value' => $data->{'title'}, 'value_formatted' => General::sanitize($data->{'title'}));
 }
开发者ID:justinjaywang,项目名称:oembed_field,代码行数:4,代码来源:oembed-content.php

示例10: dashboard_panel_validate

 public function dashboard_panel_validate($context)
 {
     if ($context['type'] != self::PANEL_NAME) {
         return;
     }
     if (isset($_POST['default']) && $_POST['default'] == 'on') {
         $config = $context['existing_config'];
         if ($config == false) {
             $config = array();
         }
         $handle = General::createHandle(self::EXT_NAME);
         $client = static::createClient($config, $context['id']);
         if (!isset($config['at'])) {
             $config['at'] = $client->getAccessToken();
         }
         foreach ($config as $key => $value) {
             Symphony::Configuration()->set($key, $value, $handle);
         }
         Symphony::Configuration()->write();
     }
 }
开发者ID:korelogic,项目名称:google_analytics_dashboard,代码行数:21,代码来源:extension.driver.php


注:本文中的General::createHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。