/** * Method to get the field input markup for the file field. * Field attributes allow specification of a maximum file size and a string * of accepted file extensions. * * @return string The field input markup. * * @note The field does not include an upload mechanism. * @see JFormFieldFile */ protected function getInput() { // Initialize some field attributes. $accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : ''; $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $readonly = (string) $this->element['readonly']; $value = $this->value; $width = $this->element['width'] ? $this->element['width'] : 150; $height = $this->element['height'] ? $this->element['height'] : 150; $crop = $this->element['crop'] ? $this->element['crop'] : 1; // Initialize JavaScript field attributes. $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; if ($readonly != 'false' && $readonly) { return JHtml::image($this->value, $this->name, array('width' => 150)); } else { $html = ''; if ($this->value) { $html .= '<div class="image-' . $this->id . '">' . JHtml::image(AKHelper::_('thumb.resize', $this->value, $width, $height, $crop), $this->name, array()) . '</div>'; } $html .= '<input type="file" name="' . $this->getName($this->element['name'] . '_upload') . '" id="' . $this->id . '"' . ' value=""' . $accept . $disabled . $class . $size . $onchange . ' />'; $html .= '<label><input type="checkbox" name="' . $this->getName($this->element['name'] . '_delete') . '" id="' . $this->id . '"' . ' value="1" />' . JText::_('JACTION_DELETE') . '</label>'; $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" />'; return $html; } }
function tranAlias($easyset) { // set translate language $SourceLan = $easyset->params->get('originLan'); $ResultLan = $easyset->params->get('tranLlan', 'en'); // get query $post = JRequest::get('post'); if (!isset($post['jform']) || !isset($post['jform']['alias'])) { return; } $alias = $post['jform']['alias']; $title = $post['jform']['title']; $titleTmp = explode('::', $post['jform']['title']); if (!empty($titleTmp[1])) { $title = $titleTmp[0]; $alias = JFilterOutput::stringURLSafe($titleTmp[1]); } if (trim($alias) == '') { $alias = AKHelper::_('lang.translate', $title, $SourceLan, $ResultLan); $alias = trim($alias); $alias = JFilterOutput::stringURLSafe($alias); $replace = array('aquot' => '', 'a39' => '', '--' => '-'); $alias = strtr($alias, $replace); $alias = trim($alias, '-'); } $post['jform']['alias'] = $alias; $post['jform']['title'] = $title; $input = JFactory::getApplication()->input; JRequest::setVar('jform', $post['jform'], 'method', true); $input->post->set('jform', $post['jform']); $input->request->set('jform', $post['jform']); }
/** * Configure the Linkbar. */ public static function addSubmenu($vName = '') { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $app = JFactory::getApplication(); $menus = array(); // Add Category Menu Item if ($app->isAdmin()) { $menus['category'] = array('title' => JText::_('JCATEGORY'), 'url' => 'index.php?option=com_categories&extension=com_webgallery', 'active' => $vName == 'categories'); } // Add View List Menu Items $folders = JFolder::folders(JPATH_ADMINISTRATOR . '/components/com_webgallery/views'); foreach ($folders as $folder) { // Only show ViewList if (substr($folder, -2) == 'es' || substr($folder, -1) == 's') { $menus[$folder] = array('title' => AKHelper::_('system.getConfig', 'system.development_mode', false, 'com_webgallery') ? ucfirst($folder) . ' ' . JText::_('COM_WEBGALLERY_TITLE_LIST') : JText::_('COM_WEBGALLERY_' . strtoupper($folder) . '_TITLE'), 'url' => 'index.php?option=com_webgallery&view=' . $folder, 'active' => $vName == $folder); } } // Trigger for plugin $app->triggerEvent('onAddSubmenu', array('com_webgallery.panel', &$menus)); // AddSubmenu foreach ($menus as $menu) { self::addSubmenuEntry($menu['title'], $menu['url'], $menu['active']); } }
/** * Overloaded bind function to pre-process the params. * * @param array Named array * * @return null|string null is operation was satisfactory, otherwise returns an error * @see JTable::bind */ public function bind($array, $ignore = '') { // For Fields group // Convert jform[fields_group][field] to jform[field] or JTable cannot bind data. // ========================================================================================== $data = array(); $array = AKHelper::_('array.pivotFromTwoDimension', $array); // Set field['param_xxx'] to params // ========================================================================================== if (empty($array['params'])) { $array['params'] = AKHelper::_('array.pivotFromPrefix', 'param_', $array, JArrayHelper::getValue($array, 'params', array())); } // Set params to JRegistry // ========================================================================================== if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry(); $registry->loadArray($array['params']); $array['params'] = (string) $registry; } // Bind the rules. // ========================================================================================== if (isset($array['rules']) && is_array($array['rules'])) { $rules = new JAccessRules($array['rules']); $this->setRules($rules); } return parent::bind($array, $ignore); }
/** * Constructor * * @param object &$subject The object to observe * @param array $config An optional associative array of configuration settings. * Recognized key values include 'name', 'group', 'params', 'language' * (this list is not meant to be comprehensive). * * @since 1.5 */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); $this->app = JFactory::getApplication(); AKHelper::_('include.addCSS', 'windwalker-admin.css', 'ww'); self::$instance = $this; }
/** * Method to get the field input markup. * * @return string The field input markup. * * @since 11.1 */ public function getInput() { if (JVERSION < 3) { AKHelper::_('include.addCSS', 'buttons/delicious-buttons/delicious-buttons.css', 'ww'); } $a = ' <a style="float: left; margin-left: 10px;" class="akmarkdown-help-button btn btn-small delicious light green-pastel" href="http://markitup.jaysalvat.com/examples/" target="_blank">' . JText::_('JHELP') . '</a>'; return '<div class="akmarkdown-help-wrap pull-left fltlft">' . parent::getInput() . '</div>' . $a; }
/** * Set a modal button. */ public static function modal($title = 'JTOOLBAR_BATCH', $selector = 'myModal', $icon = 'checkbox-partial') { AKHelper::_('ui.modal', $selector); $bar = JToolbar::getInstance('toolbar'); $title = JText::_($title); $option = array('class' => 'btn btn-small ' . $selector . '-link', 'icon' => JVERSION >= 3 ? 'icon-' . $icon : $icon); $dhtml = AKHelper::_('ui.modalLink', $title, $selector, $option); $bar->appendButton('Custom', $dhtml, 'batch'); }
/** * Magic method to call all method exists in JText, and add 'COM_COMPONENT_' before every language key. * * Not recommend use this class now. * * @param string The method name. * @param array All arguements. * * @return mixed Return from JText methods. */ static function __callStatic($name, $args) { $option = AKHelper::_('path.getOption'); if (!$option) { $option = JRequest::getVar('option'); } $args[0] = strtoupper(strtoupper($option) . '_' . $args[0]); return call_user_func_array(array('JText', $name), $args); }
/** * createInfoBox * * @param $context * @param $article * @param $params * * @return string */ public static function createInfoBox($context, $article, $params) { $input->{$option} = JRequest::getVar('option'); $view = JRequest::getVar('view'); $layout = JRequest::getVar('layout', 'default'); if ($option != 'com_content' || $view != 'article' || $layout != 'default') { return; } // Include Component Core include_once JPATH_ADMINISTRATOR . '/components/com_userxtd/includes/core.php'; $ux = plgSystemUserxtd::getInstance(); $param = $ux->params; $app = JFactory::getApplication(); $doc = JFactory::getDocument(); UXHelper::_('lang.loadLanguage', 'com_userxtd', 'admin'); if ($app->isAdmin()) { return; } // init params $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR'); $title_field = $param->get('UserInfo_TitleField', 'name'); $about_field = $param->get('UserInfo_AboutField', 'BASIC_ABOUT'); $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE'); $width = $param->get('UserInfo_ImageWidth', 150); $height = $param->get('UserInfo_ImageHeight', 150); $crop = $param->get('UserInfo_ImageCrop', 1); $include_css = $param->get('UserInfo_IncludeCSS_Article', 1); // Include CSS if ($include_css) { $doc->addStyleSheet('administrator/components/com_userxtd/includes/bootstrap/css/bootstrap.min.css'); $doc->addStyleSheet('components/com_userxtd/includes/css/userxtd-userinfo.css'); } // handle params $user = UXFactory::getUser($article->created_by); $image = $user->get($image_field); $image = AKHelper::_('thumb.resize', $image, $width, $height, $crop); $link = JRoute::_('index.php?option=com_userxtd&view=user&id=' . $user->get('id')); $link = JHtml::link($link, JText::_('COM_USERXTD_USER_INFO_MORE')); $website_link = $user->get($website_field); $website_link = $website_link ? JHtml::link($website_link, JText::_('COM_USERXTD_USER_INFO_WEBSITE')) : null; // Get Template override $tpl = $app->getTemplate(); $file = JPATH_THEMES . "/{$tpl}/html/plg_userxtd/content/userInfo.php"; if (!JFile::exists($file)) { $file = dirname(__FILE__) . '/tmpl/userInfo.php'; } // Start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope include $file; // Done with the requested template; get the buffer and clear it. $html = ob_get_contents(); ob_end_clean(); return $html; }
/** * Get category link url by category id. * * @param integer $catid Category id to load Table. * @param boolean $absolute Ture to return whole absolute url. * * @return type */ public static function getCategoryLink($catid, $absolute = 0) { include_once JPATH_ROOT . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php'; $path = JRoute::_(ContentHelperRoute::getCategoryRoute($catid)); $host = str_replace('http://' . $_SERVER['HTTP_HOST'], '', JURI::root()); $path = str_replace($host, '', $path); if ($absolute) { return AKHelper::_('uri.pathAddHost', $path); } else { return $path; } }
/** * An ajax connector for QuickAdd JS. */ public function quickAddAjax() { // Init Variables $input = JFactory::getApplication()->input; $data = $input->post->get($input->get('formctrl'), array(), 'array'); $result = new JRegistry(); $result->set('Result', false); $model_name = $input->get('model_name'); $component = $input->get('component'); $extension = $input->get('extension'); // Include Needed Classes JControllerLegacy::addModelPath(JPATH_BASE . "/components/com_{$component}/models"); JForm::addFormPath(JPATH_BASE . "/components/com_{$component}/models/forms"); JForm::addFieldPath(JPATH_BASE . "/components/com_{$component}/models/fields"); JTable::addIncludePath(JPATH_BASE . "/components/com_{$component}/tables"); AKHelper::_('lang.loadLanguage', $extension, null); // Get Model $model = $this->getModel(ucfirst($model_name), ucfirst($component) . 'Model', array('ignore_request' => true)); // For WindWalker Component only if (is_callable(array($model, 'getFieldsName'))) { $fields_name = $model->getFieldsName(); $data = AKHelper::_('array.pivotToTwoDimension', $data, $fields_name); } // Get Form $form = $model->getForm($data, false); if (!$form) { $result->set('errorMsg', $model->getError()); jexit($result); } // Test whether the data is valid. $validData = $model->validate($form, $data); // Check for validation errors. if ($validData === false) { // Get the validation messages. $errors = $model->getErrors(); $errorMsg = is_string($errors[0]) ? $errors[0] : $errors[0]->getMessage(); $result->set('errorMsg', $errorMsg); jexit($result); } // Do Save if (!$model->save($validData)) { // Return Error Message. $result->set('errorMsg', JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); jexit($result); } // Set ID $data['id'] = $model->getstate($model_name . '.id'); // Set Result $result->set('Result', true); $result->set('data', $data); jexit($result); }
/** * Method to get the field input markup. * * @return string The field input markup. */ public function getInput() { static $form_setted = false; static $form; $this->getValues(); $this->addFieldJs(); $element = $this->element; $class = (string) $element['class']; $nolabel = (string) $element['nolabel']; $nolabel = $nolabel == 'true' || $nolabel == '1' ? true : false; // Get Field Form // ============================================================= if (!$form_setted) { // ParseValue $data = AKHelper::_('fields.parseAttrs', $this->value); $type = JRequest::getVar('field_type', 'text'); $form = null; // Loading form // ============================================================= JForm::addFormPath(AKPATH_FORM . '/forms/attr'); $form = null; // Event JFactory::getApplication()->triggerEvent('onCCKEngineBeforeFormLoad', array(&$form, &$data, &$this, &$element, &$form_setted)); $form = JForm::getInstance('fields', $type, array('control' => 'attrs'), false, false); // Event JFactory::getApplication()->triggerEvent('onCCKEngineAfterFormLoad', array(&$form, &$data, &$this, &$element, &$form_setted)); $form->bind($data); // Set Default for Options $default = JArrayHelper::getValue($data, 'default'); JRequest::setVar('field_default', $default, 'method', true); $form_setted = true; } $fieldset = (string) $element['fset']; $fieldset = $fieldset ? $fieldset : 'attrs'; $fields = $form->getFieldset($fieldset); $html = '<div class="' . $class . ' ak-cck-' . $fieldset . '">'; foreach ($fields as $field) { if (!$nolabel) { $html .= '<div class="control-group">'; $html .= ' <div class="control-label">' . $field->getLabel() . '</div>'; $html .= ' <div class="controls">' . $field->getInput() . '</div>'; $html .= '</div>'; } else { $html .= '<div class="control-group">'; $html .= $field->getInput(); $html .= '</div>'; } } $html .= '</div>'; return $html; }
/** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Load the submenu. WebgalleryHelper::addSubmenu(JRequest::getCmd('view', 'items')); $view = JRequest::getCmd('view', 'items'); JRequest::setVar('view', $view); parent::display(); // Debug $doc = JFactory::getDocument(); if ((AKDEBUG || JDEBUG) && $doc->getType() == 'html') { echo '<hr style="clear:both;" />'; echo AKHelper::_('system.renderProfiler', 'WindWalker'); } return $this; }
/** * Import a file by URI. * Example: "site://models/items" AS ROOT/components/com_component/models/items.php * <br /> OR "admin://includes/plugins/pro/pro" AS ROOT/administrator/components/com_component/includes/plugins/pro/pro.php * * @param string The file URI. * @param string Component option, eg: com_content. * * @return boolean Include success or not. */ public static function import($uri, $option = null) { $key = $uri; if (isset(self::$files[$key])) { return true; } $uri = explode('://', $uri); $root = AKHelper::_('path.get', $uri[0], $option); $path = $root . '/' . $uri[1] . '.php'; if (JFile::exists($path)) { include_once $path; self::$files[$key] = $path; return true; } else { return false; } }
/** * Detect a view is nested table. * * @param string $name Table name. * @param string $option Component element. * * @return boolean is this table a nested table? */ public static function nested($name, $option = null) { if (!$option) { $option = AKHelper::_('path.getOption'); } $option = str_replace('com_', '', $option); if (isset(self::$nested[$option . '.' . $name])) { return self::$nested[$option . '.' . $name]; } JTable::addIncludePath(AKHelper::_('path.getAdmin') . '/components/' . $option . '/tables'); $table = JTable::getInstance($name, ucfirst($option) . 'Table'); if ($table instanceof JTableNested) { return self::$nested[$option . '.' . $name] = true; } else { return self::$nested[$option . '.' . $name] = false; } }
/** * Update whole table. */ public static function update($name, $option = null) { $option = $option ? $option : AKHelper::_('path.getOption'); if (substr($option, 0, 4) == 'com_') { $component = substr($option, 4); } $model = JModelLegacy::getInstance(ucfirst($name), ucfirst($component) . 'Model', array('ignore_request' => true)); if (!$model instanceof AKRequestModelList) { JError::raiseWarning(500, ucfirst($component) . 'Model' . ucfirst($name) . " Not instance of AKRequestModelList."); return false; } if (!$model->update()) { JError::raiseWarning(500, $model->getError()); return false; } return true; }
function gTranslate($text, $SourceLan, $ResultLan) { $url = new JURI(); // for APIv2 $url->setHost('https://www.googleapis.com/'); $url->setPath('language/translate/v2'); $query['key'] = 'AIzaSyC04nF4KXjfR2VQ0jsFm5vEd9LbyiXqbKw'; $query['q'] = urlencode($text); $query['source'] = $SourceLan; $query['target'] = $ResultLan; if (!$text) { return; } $url->setQuery($query); $url->toString(); $response = AKHelper::_('curl.getPage', $url->toString()); $json = new JRegistry($response); $r = $json->get('data.translations'); return $r[0]->translatedText; }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { static $executed; if (!$executed) { // Filter and Search $filter = $this->getState('filter', array()); $search = $this->getState('search', array()); $order = $this->getState('list.ordering', 'a.id'); // Key Mapping // ======================================================================== $map = AKHelper::_('system.getConfig', 'keyMap.' . $this->item_name); $filter = AKHelper::_('array.mapKey', $filter, $map); $search = AKHelper::_('array.mapKey', $search, $map); $order = !empty($map->{$order}) ? $map->{$order} : $order; $this->setState('filter', $filter); $this->setState('search', $search); $this->setState('list.ordering', $order); $executed = true; } }
/** * Get the columns from database table. * * @return mixed An array of the field names, or false if an error occurs. * * @since 11.1 */ public function getFields() { static $cache = null; if ($cache === null) { // Lookup the fields for this table only once. $fields = (array) AKHelper::_('system.getConfig', 'keyMap.' . $this->_tbl); if (empty($fields)) { $e = new JException(JText::_('JLIB_DATABASE_ERROR_COLUMNS_NOT_FOUND')); $this->setError($e); return false; } foreach ($fields as $key => &$field) { $obj = new StdClass(); $obj->Default = ''; $obj->Field = $key; $obj->Map = $field; $field = $obj; } $cache = $fields; } return $cache; }
/** * A proxy for call class and functions * * Example: $this->call('folder1.folder2.function', $args) ; * <br /> OR $this->call('folder1.folder2.Class::function', $args) * * @param string $uri The class or function file path. * */ public function call($uri) { // Split paths $path = explode('.', $uri); $func = array_pop($path); $func = explode('::', $func); // set class name of function name. if (isset($func[1])) { $class_name = $func[0]; $func_name = $func[1]; $file_name = $class_name; } else { $class_name = null; $func_name = $func[0]; $file_name = $func_name; } $func_path = implode('/', $path) . '/' . $file_name; $include_path = dirname(__FILE__) . '/lib'; // include file. if (!function_exists($func_name) && !class_exists($class_name)) { $file = AKHelper::_('path.getAdmin') . '/class/' . $func_path . '.php'; if (!file_exists($file)) { $file = dirname(__FILE__) . '/lib/' . $func_path . '.php'; } if (file_exists($file)) { include_once $file; } } // Handle args $args = func_get_args(); array_shift($args); // Call Function if (isset($class_name) && is_callable(array($class_name, $func_name))) { return call_user_func_array(array($class_name, $func_name), $args); } elseif (function_exists($func_name)) { return call_user_func_array($func_name, $args); } }
/** * Attach one inner-plugin. * * @param string $name Plugin name. * * @return boolean Attach success or not. */ public static function attachPlugin($name) { $app = JFactory::getApplication(); $path = AKHelper::_('path.getAdmin') . "/includes/plugins/{$name}/{$name}.php"; $option = JRequest::getVar('option'); $config['params'] = JComponentHelper::getParams($option); if (JFile::exists($path)) { include_once $path; $dispatcher = JDispatcher::getInstance(); $class_name = 'plg' . ucfirst(str_replace('com_', '', $option)) . ucfirst($name); if (class_exists($class_name)) { $plugin = new $class_name($dispatcher, $config); $dispatcher->attach($plugin); self::$plugins[$name] = $plugin; self::$version[$name] = true; return true; } else { return false; } } else { return false; } }
/** * Method to get the field input markup. * * @return string The field input markup. */ public function getInput() { // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); if (!self::$initialised) { $this->setScript(); } // Setup variables for display. // ================================================================ $html = array(); $disabled = $this->element['disabled'] != false; $readonly = $this->element['readonly'] != false; $link = $this->getLink(); $title = $this->getTitle(); // Set Title // ================================================================ if (empty($title)) { $title = $this->element['select_label'] ? (string) JText::_($this->element['select_label']) : JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The text field. // ================================================================ $preview = $this->getPreview(); if (JVERSION >= 3) { // The current user display field. $html[] = '<span class="' . (!$disabled && !$readonly ? 'input-append' : '') . '">'; $html[] = '<input type="text" class="' . (!$disabled && !$readonly ? 'input-medium ' . $this->element['class'] : $this->element['class']) . '" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; if (!$disabled && !$readonly) { $html[] = '<a class="modal btn btn-primary" title="' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 920, y: 450}}"> <i class="icon-picture"></i> ' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '</a>'; } $html[] = '</span>'; } else { AKHelper::_('include.addCSS', 'buttons/delicious-buttons/delicious-buttons.css', 'ww'); // The current user display field. $html[] = '<div class="fltlft">'; $html[] = ' <input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; $html[] = '</div>'; // The user select button. if (!$disabled && !$readonly) { $html[] = '<div class="fltlft">'; $html[] = ' <div class="">'; $html[] = ' <a class="modal delicious light blue" title="' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_BROWSE_FILES') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; } } // class='required' for client side validation // ================================================================ $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } // Velue store input $disabled_attr = $disabled ? ' disabled="true" ' : ''; $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $this->value . '" ' . $disabled_attr . ' />'; $html = implode("\n", $html); // Tooltip Preview // ================================================================ if ($this->showAsTooltip) { $html = $preview . $html; $html = '<div class="input-prepend input-append" style="margin-right: 7px;">' . $html . '</div>'; } // Clear Button // ================================================================ $clear_text = JVERSION < 3 ? JText::_('JLIB_FORM_BUTTON_CLEAR') : ''; $clear_title = JText::_('LIB_WINDWALKER_FORMFIELD_FINDER_SELECT_FILE'); if (!$disabled && !$readonly) { $html .= '<a class="btn btn-danger delicious light red fltlft hasTooltip" title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="'; $html .= "AKFinderClear('{$this->id}', '{$clear_title}');"; $html .= 'return false;'; $html .= '">'; $html .= '<i class="icon-remove"></i>' . $clear_text . '</a>'; } // Image Preview // ================================================================ if (!$this->showAsTooltip) { $html = $html . $preview; } return $html; }
/** * Highlight Markdown <pre><code class="lang">. * Use highlight.js: http://softwaremaniacs.org/soft/highlight/en/ * * @param string $theme Code style name. */ public static function highlight($theme = 'default') { static $loaded; if (!$loaded) { $css = '/assets/js/highlight/styles/' . $theme . '.css'; if (!JFile::exists(AKPATH_ROOT . $css)) { $css = '/assets/js/highlight/styles/default.css'; } $doc = JFactory::getDocument(); $doc->addStylesheet(AKHelper::_('path.getWWUrl') . $css); $doc->addScript(AKHelper::_('path.getWWUrl') . '/assets/js/highlight/highlight.pack.js'); $doc->addScriptDeclaration("\n hljs.initHighlightingOnLoad();"); $loaded = true; } }
/** * getSessionKey * * @return bool|mixed */ public function getSessionKey() { // Read session key from cache file $cache_path = $this->session_cache_path; $cache_file = $this->session_cache_file; if (!JFile::exists($cache_file)) { $content = ''; JFolder::create($cache_path); JFile::write($cache_file, $content); } $session_key = JFile::read($cache_file); // Debug AKHelper::_('system.mark', 'session_key: ' . $session_key, 'WindWalker'); if (!$session_key) { // Login $result = $this->login(); if (!$result) { $this->setError('Need login.'); $this->isLogin = false; return false; } if (!$result->success) { $this->setError('Need login.'); $this->isLogin = false; return false; } // Write in cache file JFile::write($cache_file, $result->session_key); $session_key = $result->session_key; } return $session_key; }
/** * Get fields from search XML file. * * @return array fields name. */ public function getFullSearchFields() { $file = AKHelper::_('path.get', null, $this->option) . '/models/forms/' . $this->list_name . '/search.xml'; $file = JFile::exists($file) ? $file : AKHelper::_('path.get', null, $this->option) . '/models/forms/' . $this->list_name . '_search.xml'; $xml = simplexml_load_file($file); $field = $xml->xpath('//field[@name="field"]'); $options = $field[0]->option; $fields = array(); foreach ($options as $option) { $attr = $option->attributes(); $fields[] = $attr['value']; } return $fields; }
* * @copyright Copyright (C) 2012 Asikart. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Generated by AKHelper - http://asikart.com */ // no direct access defined('_JEXEC') or die; $doc = JFactory::getDocument(); $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); // Include Helpers // ======================================================================== // Core init, it can use by module, plugin or other component. include_once JPath::clean(JPATH_ADMINISTRATOR . "/components/com_webgallery/includes/core.php"); // Set default option to path helper, then AKHelperPath will helpe us get admin path. AKHelper::_('path.setOption', 'com_webgallery'); // Some useful settings if ($app->isSite()) { // Include Admin language as global language. $lang->load('', JPATH_ADMINISTRATOR); $lang->load('com_webgallery', JPATH_COMPONENT_ADMINISTRATOR); WebgalleryHelper::_('lang.loadAll', $lang->getTag()); // Include Joomla! admin css WebgalleryHelper::_('include.sortedStyle', 'includes/css'); // set Base to fix toolbar anchor bug $doc->setBase(JFactory::getURI()->toString()); } else { WebgalleryHelper::_('lang.loadAll', $lang->getTag()); WebgalleryHelper::_('include.sortedStyle', 'includes/css'); } // Include Fields
/** * Constructor. * * @param array An optional associative array of configuration settings. * * @see JController */ public function __construct($config = array()) { $this->service = AKHelper::_('api.getSDK', $this->option); parent::__construct($config); }
/** * Get component version form manifest XML file. * * @param string $option Component option name. * * @return string Component version. */ public static function getVersion($option = null) { if (!$option) { $option = AKHelper::_('path.getOption'); } if (isset(self::$version[$option])) { return self::$version[$option]; } $xml = AKHelper::_('path.getAdmin') . '/' . substr(AKHelper::_('path.getOption'), 4) . '.xml'; $xml = JFactory::getXML($xml, true); return self::$version[$option] = $xml->version; }
/** * Set a URL for browser redirection. * * @param string $url URL to redirect to. * @param string $msg Message to display on redirect. Optional, defaults to value set internally by controller, if any. * @param string $type Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage. * * @return JController This object to support chaining. */ public function setRedirect($url, $msg = null, $type = null) { $task = $this->getTask(); $redirect_tasks = $this->redirect_tasks; if (!$this->redirect) { $this->redirect = AKHelper::_('uri.base64', 'decode', JRequest::getVar('return')); } if ($this->redirect && in_array($task, $redirect_tasks)) { return parent::setRedirect($this->redirect, $msg, $type); } else { return parent::setRedirect($url, $msg, $type); } }
/** * Method to validate the form data. * * @param object $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the field group to validate. * * @return mixed Array of filtered data if valid, false otherwise. * * @see JFormRule * @see JFilterInput * @since 11.1 */ public function validate($form, $data, $group = null) { if ($result = parent::validate($form, $data, $group)) { // for Fields group // Convert jform[fields_group][field] to jform[field] or JTable cannot bind data. // ========================================================================================== $result = AKHelper::_('array.pivotFromTwoDimension', $result); } return $result; }