/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. * * @since 11.4 */ protected function getOptions() { // Initialise variables $folder = $this->element['folder']; if (!empty($folder)) { // Get list of plugins $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = "' . $folder . '"'); $query->where('enabled = 1'); $query->order('ordering, name'); $db->setQuery($query); $options = $db->loadObjectList(); $lang = JFactory::getLanguage(); foreach ($options as $i => $item) { $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value; $extension = 'plg_' . $folder . '_' . $item->value; $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false); $options[$i]->text = rc__($item->text); } if ($db->getErrorMsg()) { JError::raiseWarning(500, rc__('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); return ''; } } else { JError::raiseWarning(500, rc__('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get the field label markup for a spacer. * Use the label text or name from the XML element as the spacer or * Use a hr="true" to automatically generate plain hr markup * * @return string The field label markup. * * @since 11.1 */ public function getLabel() { $html = array(); $class = $this->element['class'] ? (string) $this->element['class'] : ''; $html[] = '<span class="spacer">'; $html[] = '<span class="before"></span>'; $html[] = '<span class="' . $class . '">'; if ((string) $this->element['hr'] == 'true') { $html[] = '<hr class="' . $class . '" />'; } else { $label = ''; // Get the label text from the XML element, defaulting to the element name. $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name']; $text = $this->translateLabel ? rc__($text) : $text; // Build the class for the label. $class = !empty($this->description) ? 'hasTip' : ''; $class = $this->required == true ? $class . ' required' : $class; // Add the opening label tag and main attributes attributes. $label .= '<label id="' . $this->id . '-lbl" class="' . $class . '"'; // If a description is specified, use it to build a tooltip. if (!empty($this->description)) { $label .= ' title="' . htmlspecialchars(trim($text, ':') . '::' . ($this->translateDescription ? rc__($this->description) : $this->description), ENT_COMPAT, 'UTF-8') . '"'; } // Add the label text and closing tag. $label .= '>' . $text . '</label>'; $html[] = $label; } $html[] = '</span>'; $html[] = '<span class="after"></span>'; $html[] = '</span>'; return implode('', $html); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ public function getInput() { // Initialize variables. $html = array(); // Initialize some field attributes. $class = $this->element['class'] ? ' class="radio ' . (string) $this->element['class'] . '"' : ' class="radio"'; // Start the radio field output. $html[] = '<fieldset id="' . $this->id . '"' . $class . '>'; // Get the field options. $options = $this->getOptions(); // Build the radio field output. foreach ($options as $i => $option) { // Initialize some option attributes. $checked = (string) $option->value == (string) $this->value ? ' checked="checked"' : ''; $class = !empty($option->class) ? ' class="' . $option->class . '"' : ''; $disabled = !empty($option->disable) ? ' disabled="disabled"' : ''; // Initialize some JavaScript option attributes. $onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : ''; $html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>'; $html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . rc__($option->text) . '</label>'; } // End the radio field output. $html[] = '</fieldset>'; return implode($html); }
/** * Method to get the field options for the list of installed editors. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { JLog::add('RokCommon_Form_Field_Editors is deprecated. Use RokCommon_Form_Field_Plugins instead (with folder="editors").', JLog::WARNING, 'deprecated'); // Get the database object and a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); $query->order('ordering, name'); // Set the query and load the options. $db->setQuery($query); $options = $db->loadObjectList(); $lang = JFactory::getLanguage(); foreach ($options as $i => $option) { $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, JPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false); $options[$i]->text = rc__($option->text); } // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
function display($tpl = null) { JHTML::_('behavior.mootools'); JHTML::_('behavior.keepalive'); $app =& JFactory::getApplication(); $document =& JFactory::getDocument(); $id = (int) JRequest::getVar('id'); $force_fixed_size = JRequest::getVar('fixed', 0); $name = JRequest::getVar('name'); $galleries = RokGallery_Model_GalleryTable::getAll(); $current_gallery = false; if (null != $id) { $current_gallery = RokGallery_Model_GalleryTable::getSingle($id); } if (null != $name) { $default_name = $name . rc__('ROKGALLERY_GALLERY_CREATE_DEFAULT_EXTENSION'); } $this->assign('default_name', $default_name); $this->assign('current_gallery_id', $id); $this->assign('force_fixed_size', $force_fixed_size); $this->assignRef('galleries', $galleries); $this->assignRef('current_gallery', $current_gallery); $this->assign('context', 'com_rokgallery.gallerymanager'); $this->setLayout('default'); parent::display($tpl); }
/** * Method to get the custom field options. * Use the query attribute to supply a query to generate the list. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $query = (string) $this->element['query']; // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Check for an error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); return $options; } // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = RokCommon_HTML_SelectList::option($item->{$key}, rc__($item->{$value})); } else { $options[] = RokCommon_HTML_SelectList::option($item->{$key}, $item->{$value}); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get the field options for the list of installed editors. * * @return array The field option objects. * @since 11.1 */ protected function getOptions() { $container = RokCommon_Service::getContainer(); /** @var $model RokSprocket_Model_Widgets */ $model = $container->getService('roksprocket.widgets.model'); $widgets = $model->getAvailableInstances(); $fieldname = $this->element['name']; $options = array(); $options[] = RokCommon_HTML_SelectList::option('', rc__('- Select RokSprocket Widget -')); foreach ($widgets as $info) { if ($this->value == $info['id']) { $selected = ' selected="selected"'; } else { $selected = ""; } $tmp = RokCommon_HTML_SelectList::option($info['id'], $info['title']); $options[] = $tmp; } $options = array_merge(parent::getOptions(), $options); foreach ($options as &$option) { // Set some option attributes. $option->attr = array('class' => $option->value, 'rel' => $fieldname . '_' . $option->value); } reset($options); return $options; }
/** * Get the full list of jobs * <code> * { * 'ids': [1,2,3], * 'settings': {'pubished':true} * } * </code> * @param $params * @return RokCommon_Ajax_Result */ public function update($params) { $result = new RokCommon_Ajax_Result(); try { try { RokGallery_Doctrine::getConnection()->beginTransaction(); if (count($params->settings) <= 0) { throw new RokCommon_Ajax_Exception(rc__('ROKGALLERY_NO_SETTINGS_PASSED_TO_UPDATE')); } $q = Doctrine_Query::create()->update('RokGallery_Model_File'); foreach ($params->settings as $column => $value) { $q->set($column, '?', $value); } $q->whereIn('id', $params->ids); $q->execute(); RokGallery_Doctrine::getConnection()->commit(); } catch (Exception $e) { RokGallery_Doctrine::getConnection()->rollback(); throw $e; } } catch (Exception $e) { throw $e; } return $result; }
/** * */ public function reset() { $this->xml = new RokCommon_XMLElement('<config/>'); foreach ($this->sections as $identifier => &$section) { $this->logger->debug(rc__('Resetting options section %s.', $identifier)); $section->reset(); } }
/** * Apply the manipulation with the setup options to the passed in image. * This does not do any memory manipulation * * @param WideImage_Image $image * @return WideImage_Image */ public function &apply(WideImage_Image &$image) { if (!$this->isSetup()) { throw new RokGallery_Manipulation_Exception(rc__('ROKGALLERY_MANIPULATION_WAS_NOT_SETUP_PRIOR_TO_APPLYING')); } $return_image = $image->resize($this->width, $this->height); return $return_image; }
function rc_alt($string, $alt) { $out = rc__($string . '_' . $alt); if ($out == $string . '_' . $alt) { $out = rc__($string); } return $out; }
/** * Display the view */ public function display($tpl = null) { JHTML::_('behavior.mootools'); JHTML::_('behavior.keepalive'); $this->container = RokCommon_Service::getContainer(); $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->articles = $this->getModel()->getArticles($this->item->id, $this->item->params); $this->layout = isset($this->item->params['layout']) ? $this->item->params['layout'] : $this->form->getFieldAttribute('layout', 'default', 'text', 'params'); $this->provider = isset($this->item->params['provider']) ? $this->item->params['provider'] : $this->form->getFieldAttribute('provider', 'default', 'text', 'params'); if (!isset($this->container[sprintf('roksprocket.layouts.%s', $this->layout)])) { JError::raiseWarning(500, rc__(ROKSPROCKET_UNABLE_TO_FIND_LAYOUT_ERROR, $this->layout)); $app = JFactory::getApplication(); $app->redirect(JRoute::_(sprintf('index.php?option=%s&view=modules', RokSprocket_Helper::getRedirectionOption()), false)); return false; } $this->perItemForm = $this->getModel()->getPerItemsForm($this->layout); /** @var $i18n RokCommon_I18N */ $i18n = $this->container->i18n; foreach ($this->container['roksprocket.layouts'] as $layout_type => $layoutinfo) { $layout_lang_paths = $this->container[sprintf('roksprocket.layouts.%s.paths', $layout_type)]; foreach ($layout_lang_paths as $lang_path) { @$i18n->loadLanguageFiles('roksprocket_layout_' . $layout_type, $lang_path); } } $load_more_total = count($this->articles); $module_params = new RokCommon_Registry($this->item->params); $limit = 10; if ($load_more_total > $limit) { $this->articles = $this->articles->trim($limit); $load_more = 'true'; } else { $load_more = 'false'; } $load_more_script = sprintf('RokSprocket.Paging = {more: %s, page: 1, next_page: 2, amount: %d};', $load_more, $load_more_total); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Read cookie for showing/hide per-article items if (!isset($_COOKIE['roksprocket-showitems'])) { $showitems_cookie = 1; setcookie("roksprocket-showitems", $showitems_cookie, time() + 60 * 60 * 24 * 365, '/'); } else { $showitems_cookie = $_COOKIE['roksprocket-showitems']; } $this->showitems = (bool) $showitems_cookie; $siteURL = JURI::root(true); $adminURL = JURI::base(true); $this->addToolbar(); $this->compileLess(); $this->compileJS(); RokCommon_Header::addInlineScript("RokSprocket.params = 'jform_params';RokSprocket.SiteURL = '" . $siteURL . "'; RokSprocket.AdminURL = '" . $adminURL . "'; RokSprocket.URL = RokSprocket.AdminURL + '/index.php?option=" . JRequest::getString('option') . "&task=ajax&format=raw';" . $load_more_script); RokCommon_Header::addStyle($siteURL . '/components/com_roksprocket/fields/filters/css/datepicker.css'); parent::display($tpl); }
/** * @param RokGallery_Model_Job $job * @return RokGallery_Job_Processor * @throws RokGallery_Job_Exception */ public static function &factory(RokGallery_Job &$job) { $classname = 'RokGallery_Job_Processor_' . ucfirst(str_replace(' ', '', $job->getType())); if (!class_exists($classname, true)) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_PROCESS_FOR_JOB_TYPE_N', $job->getType())); } $ret = new $classname($job); return $ret; }
/** * */ protected function cleanItemParams() { foreach ($this->items as $item_id => &$item) { $item->setPrimaryImage($this->setupImage($item, 'mosaic_image_default', 'mosaic_image_default_custom', 'mosaic_item_image')); $item->setPrimaryLink($this->setupLink($item, 'mosaic_link_default', 'mosaic_link_default_custom', 'mosaic_item_link')); $item->setTitle($this->setupText($item, 'mosaic_title_default', 'mosaic_title_default_custom', 'mosaic_item_title')); $item->setText($this->setupText($item, 'mosaic_description_default', 'mosaic_description_default_custom', 'mosaic_item_description')); $item->setTags($this->filterTags($this->setupTags($item, 'mosaic_item_tags'))); // clean from tags and limit words amount $desc = $item->getText(); if ($this->parameters->get('mosaic_strip_html_tags', true)) { $desc = strip_tags($desc); } $words_amount = $this->parameters->get('mosaic_previews_length', 20); if ($words_amount === '∞' || $words_amount == '0') { $words_amount = false; } $htmlmanip = new RokSprocket_Util_HTMLManipulator(); $preview = $htmlmanip->truncateHTML($desc, $words_amount); $append = strlen($desc) != strlen($preview) ? '<span class="roksprocket-ellipsis">…</span>' : ""; $item->setText($preview . $append); // resizing images if needed if ($item->getPrimaryImage()) { if ($this->parameters->get('mosaic_resize_enable', false)) { $width = $this->parameters->get('mosaic_resize_width', 0); $height = $this->parameters->get('mosaic_resize_height', 0); $item->getPrimaryImage()->resize($width, $height); } /** @var RokCommon_PlatformInfo $platforminfo */ $platforminfo = $this->container->platforminfo; $urlbase = $platforminfo->getUrlBase() ? $platforminfo->getUrlBase() : '/'; if (!$platforminfo->isLinkexternal($item->getPrimaryImage()->getSource()) && strpos($item->getPrimaryImage()->getSource(), '/') !== 0 && strpos($item->getPrimaryImage()->getSource(), $urlbase) !== 0) { $source = rtrim($urlbase, '/') . '/' . $item->getPrimaryImage()->getSource(); $item->getPrimaryImage()->setSource($source); } } // ordering $item->custom_ordering_items = '<div style="display: none;" data-mosaic-order-title="' . $item->getTitle() . '" data-mosaic-order-date="' . $item->getDate() . '"></div>'; // tagging $item->custom_tags = ""; $item->custom_tags_list = array(); foreach ($this->filterTags($item->getTags()) as $key => $name) { $item->custom_tags .= " sprocket-tags-" . $key; $item->custom_tags_list[$key] = $name; if (!array_key_exists($key, $this->tagging)) { $this->tagging[$key] = $name; } } $item->custom_tags = trim($item->custom_tags); natcasesort($item->custom_tags_list); } // sort the tags for display natcasesort($this->tagging); // add the all $this->tagging = array('all' => rc__('ALL')) + $this->tagging; }
public function getInput() { $fieldname = $this->element['name']; $js = "RokSprocket.dynamicfields.add('" . $this->id . "', '" . $fieldname . "');"; // Initialize variables. $html = array(); $attr = ''; $css_classes = explode(' ', (string) $this->element['class']); $css_classes = array_merge($css_classes, $this->getProviderClasses()); $css_classes[] = strtolower($this->type); $css_classes[] = 'chzn-done'; $css_classes = array_unique($css_classes); $attr .= ' class="' . implode(' ', $css_classes) . '"'; // Initialize some field attributes. // $this->element['class'] = $this->element['class'] ? (string)$this->element['class'] . " " . strtolower($this->type) : strtolower($this->type); // $attr .= $this->element['class'] ? ' class="' . (string)$this->element['class'] . ' chzn-done"' : ' class="chzn-done"'; // To avoid user's confusion, readonly="true" should imply disabled="true". if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') { $attr .= ' disabled="disabled"'; } $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; $attr .= $this->element['refresher'] ? ' data-refresher="true" ' : ""; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; if ($this->element['attrs']) { $additional_attrs = explode(',', (string) $this->element['attrs']); foreach ($additional_attrs as $additional_attr) { $additional_attr = strtolower(trim($additional_attr)); $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : ''; } } // Get the field options. $options = (array) $this->getOptions(); RokCommon_Header::addInlineScript($js); if ((string) $this->element['readonly'] == 'true') { $html[] = rc__('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id); $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>'; } else { if (count($options) == 1) { $icon = isset($options[0]->icon) ? $options[0]->icon : ""; if (strlen($icon)) { $icon_html = '<i data-dynamic="false" class="icon ' . $this->element['name'] . " " . $options[0]->value . '"></i>'; } else { $icon_html = ""; } $html[] = '<div class="single-layout">' . $icon_html . ' ' . $options[0]->text . "</div>\n"; $attr .= ' style="display: none;" '; } $listattr = array('list.attr' => $attr, 'id' => $this->id, 'list.select' => $this->value, 'option.text' => 'text', 'option.value' => 'value', 'option.attr' => 'attr'); $list = RokCommon_HTML_SelectList::genericlist($options, $this->name, $listattr); $html[] = $list; } return implode('', $html); }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { // Initialize variables. $options = array(); // Convert to name => name array. foreach (JCache::getStores() as $store) { $options[] = RokCommon_HTML_SelectList::option($store, rc__('JLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text'); } $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getLabel() { $label = $this->type; if (isset($this->element['label']) && !empty($this->element['label'])) { $label = rc__((string) $this->element['label']); $description = rc__((string) $this->element['description']); return '<label class="sprocket-tip" title="' . $description . '">' . $label . '</label>'; } else { return; } }
/** * @param string $provider_name */ public function __construct($provider_name = 'unsupported') { $this->container = RokCommon_Service::getContainer(); $this->provider_name = $provider_name; $this->filter_file = $this->container['roksprocket.providers.registered.' . $provider_name . '.path'] . '/' . $this->container['roksprocket.providers.registered.' . $provider_name . '.filter.file']; if (!file_exists($this->filter_file)) { throw new Exception(rc__('Unable to find filter file for %1s at path %2s.', $provider_name, $this->filter_file)); } $xmlfile = simplexml_load_file($this->filter_file); $this->filter = new RokCommon_Filter($xmlfile); }
/** * Apply the manipulation with the setup options to the passed in image. * This does not do any memory manipulation * * @param WideImage_Image $image * @return WideImage_Image */ public function &apply(WideImage_Image &$image) { if (!$this->isSetup()) { throw new RokGallery_Manipulation_Exception(rc__('ROKGALLERY_MANIPULATION_WAS_NOT_SETUP_PRIOR_TO_APPLYING')); } if ($this->left == 0 && $this->top == 0 && $this->width == 0 && $this->height == 0) { $this->width = $image->getWidth(); $this->height = $image->getHeight(); } $return_image = $image->crop($this->left, $this->top, $this->width, $this->height); return $return_image; }
/** * Method to get the session handler field options. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { // Initialize variables. $options = array(); // Get the options from JSession. foreach (JSession::getStores() as $store) { $options[] = RokCommon_HTML_SelectList::option($store, rc__('JLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text'); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public static function unserializeFromJson($json_array) { $manipulations = array(); foreach ($json_array as $json_manip) { $classname = 'RokGallery_Manipulation_Action_' . ucfirst($json_manip->action); if (!class_exists($classname)) { throw new RokGallery_Manipulation_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_PASSED_MANIPULATION_ACTION_N', $json_manip->action)); } $action = new $classname($json_manip->options); $manipulations[] = $action; } return $manipulations; }
/** * Delete the file and all associated rows (done by foreign keys) and files * $params object should be a json like * <code> * { * 'id': 'xxxx-x-x-x-x-x-x' * } * </code> * * @param $params * @return RokCommon_Ajax_Result */ public function file($params) { $result = new RokCommon_Ajax_Result(); $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('READ UNCOMMITTED'); try { if (count($_FILES) == 0) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NO_FILES_SENT')); } $job = RokGallery_Job::get($params->id); if ($job === false) { throw new RokCommon_Ajax_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_JOB', $params->id)); } if ($job->getStateName() != RokGallery_Job::STATE_PREPPING) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NOT_IN_PREPPING_STATUS')); } if ($job->getType() != RokGallery_Job::TYPE_IMPORT) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NOT_AN_IMPORT_JOB')); } $job_properties = $job->getProperties(); if (empty($job_properties)) { $job_properties = array(); } $basepath = RokGallery_Config::getOption(RokGallery_Config::OPTION_JOB_QUEUE_PATH) . DS . $job->getId(); if (!file_exists($basepath)) { @mkdir($basepath); RokGallery_Queue_DirectoryCreate::add($basepath); } if (!(file_exists($basepath) && is_dir($basepath) && is_writable($basepath))) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_UNABLE_TO_CREATE_OR_WRITE_TO_TEMP_DIR', $basepath)); } $tx->beginTransaction(); foreach ($_FILES as $uploaded_file) { if ($uploaded_file['error'] == UPLOAD_ERR_OK) { $file = new RokGallery_Job_Property_ImportFile(); $file->setFilename($uploaded_file['name']); $file->setPath($basepath . DS . $file->getId()); move_uploaded_file($uploaded_file['tmp_name'], $file->getPath()); $job_properties[] = $file; } } $job->setProperties($job_properties); $job->save(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } return $result; }
protected function _load($id) { try { $this->_job = Doctrine_Core::getTable('RokGallery_Model_Job')->getSingle($id); if ($this->_job === false) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_ID', $id)); } $this->_fsm = unserialize($this->_job->sm); $this->_fsm->setOwner($this); $this->_id = $this->_job->id; $this->_processor = RokGallery_Job_ProcessorFactory::factory($this); } catch (Exception $e) { throw $e; } }
public function _setOptions() { $options = array(); foreach ($this->element->children() as $option) { $name = rc__((string) $option); $value = (string) $option['value']; if ($value == 'divider') { $options['divder'] = array("name" => '', 'attributes' => array('class' => 'divider', 'data-divider' => true)); } else { $options[$value] = array("name" => $name, 'attributes' => array('value' => $value, 'data-value' => $value, 'icon' => false)); } } $this->options = $options; return $options; }
/** * @param $properties * @param $action_desc * @return bool */ protected function _checkState(&$properties, $action_desc) { $this->_job->refreshState(); if ($this->_job->getStateName() == RokGallery_Job::STATE_PAUSING) { $this->_job->setProperties($properties); $this->_job->Paused(rc__('ROKGALLERY_N_PAUSED', $action_desc), $this->_job->getJob()->percent); return false; } if ($this->_job->getStateName() == RokGallery_Job::STATE_CANCELING) { $this->_job->setProperties($properties); $this->_job->Canceled(rc__('ROKGALLERY_N_CANCELED', $action_desc), $this->_job->getJob()->percent); return false; } return true; }
/** */ public function process() { try { /** @var $properties RokGallery_Job_Property_ImportFile[] */ $properties = $this->_job->getProperties(); $total_files = count($properties['files']); foreach ($properties['files'] as $key => &$file) { // keep bumping the time as log as a file doesnt take 30 seconds or more /** @var RokGallery_Job_Property_ImportFile $file */ if (!$this->_checkState($properties, rc__('ROKGALLERY_CREATE_UPDATE'))) { return; } if ($file->isCompleted()) { continue; } RokGallery_Doctrine::getConnection()->beginTransaction(); $gallery = RokGallery_Model_GalleryTable::getSingle($properties['galleryId']); if ($gallery === false) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NOT_A_VALID_GALLERY')); } $full_file = RokGallery_Model_FileTable::getSingle($file->getId()); if ($full_file === false) { $file->setStatus(rc__('ROKGALLERY_UNABLE_TO_FIND_FILE')); $file->setError(true); RokGallery_Doctrine::getConnection()->commit(); continue; } if ($gallery && $full_file) { $full_file->updateSlicesForGallery($gallery); } $file->setCompleted(); $percent = (int) (($key + 1) / $total_files * 100); $this->_job->setProperties($properties); $this->_job->save(rc__('ROKGALLERY_UPDATED_GALLERY_SLICE_FOR_FILE_N', $full_file->title), $percent); RokGallery_Doctrine::getConnection()->commit(); } $this->_job->Complete(rc__('ROKGALLERY_GALLERY_UPDATE_COMPLETE')); if (RokGallery_Config::getOption(RokGallery_Config::OPTION_AUTO_CLEAR_SUCCESSFUL_JOBS, false)) { sleep(5); $this->_job->Delete(); } return; } catch (Exception $e) { RokGallery_Doctrine::getConnection()->rollback(); $this->_job->Error($e->getMessage()); return; } }
/** * Method to test the value. * * @param object &$element The JXmlElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * @param object &$input An optional JRegistry object with the entire data set to validate against the entire form. * @param object &$form The form object for which the field is being tested. * * @throws RokCommon_Exception * @return boolean True if the value is valid, false otherwise. * * @since 11.1 */ public function test(&$element, $value, $group = null, &$input = null, &$form = null) { // Check for a valid regex. if (empty($this->regex)) { throw new RokCommon_Exception(rc__('JLIB_FORM_INVALID_FORM_RULE', get_class($this))); } // Add unicode property support if available. if (JCOMPAT_UNICODE_PROPERTIES) { $this->modifiers = strpos($this->modifiers, 'u') !== false ? $this->modifiers : $this->modifiers . 'u'; } // Test the value against the regular expression. if (preg_match(chr(1) . $this->regex . chr(1) . $this->modifiers, $value)) { return true; } return false; }
/** * */ protected function cleanItemParams() { $this->tagging['all'] = rc__('ALL'); foreach ($this->items as $item_id => &$item) { $item->setPrimaryImage($this->setupImage($item, 'mosaic_image_default', 'mosaic_image_default_custom', 'mosaic_item_image')); $item->setPrimaryLink($this->setupLink($item, 'mosaic_link_default', 'mosaic_link_default_custom', 'mosaic_item_link')); $item->setTitle($this->setupText($item, 'mosaic_title_default', 'mosaic_title_default_custom', 'mosaic_item_title')); $item->setText($this->setupText($item, 'mosaic_description_default', 'mosaic_description_default_custom', 'mosaic_item_description')); // clean from tags and limit words amount $desc = $item->getText(); if ($this->parameters->get('mosaic_strip_html_tags', true)) { $desc = strip_tags($desc); } $words_amount = $this->parameters->get('mosaic_previews_length', 20); if ($words_amount === '∞' || $words_amount == '0') { $words_amount = false; } $htmlmanip = new RokSprocket_Util_HTMLManipulator(); $preview = $htmlmanip->truncateHTML($desc, $words_amount); $append = strlen($desc) != strlen($preview) ? '<span class="roksprocket-ellipsis">…</span>' : ""; $item->setText($preview . $append); // resizing images if needed if ($item->getPrimaryImage() && $this->parameters->get('mosaic_resize_enable', false)) { $width = $this->parameters->get('mosaic_resize_width', 0); $height = $this->parameters->get('mosaic_resize_height', 0); $item->getPrimaryImage()->resize($width, $height); } // ordering $item->custom_ordering_items = '<div style="display: none;" data-mosaic-order-title="' . $item->getTitle() . '" data-mosaic-order-date="' . $item->getDate() . '"></div>'; // tagging $tags = $item->getParam('mosaic_item_tags', false); $tags = $tags ? explode(",", $tags) : array(); $item->custom_tags = ""; $item->custom_tags_list = array(); foreach ($tags as $tag) { $cleanName = trim($tag); $key = str_replace(' ', '-', str_replace(array("'", '"'), '', $cleanName)); $name = $this->_camelize($cleanName, true, true); $item->custom_tags .= " sprocket-tags-" . $key; $item->custom_tags_list[$key] = $name; if (!array_key_exists($key, $this->tagging)) { $this->tagging[$key] = $name; } } $item->custom_tags = trim($item->custom_tags); } }
/** * $params object should be a json like * <code> * { * "id": 1 // this is the slice ID displayed * } * @throws Exception|RokCommon_Ajax_Exception * @param $params * @return RokCommon_Ajax_Result */ public function remove($params) { try { $result = new RokCommon_Ajax_Result(); $slice = RokGallery_Model_SliceTable::getSingle($params->id); if ($slice === false) { throw new RokCommon_Ajax_Exception('No Slice Found'); } if (RokCommon_Session::get(self::CONTEXT_ROOT . $slice->file_id, false)) { $slice->decrementLoves(); RokCommon_Session::clear(self::CONTEXT_ROOT . $slice->file_id); } $result->setPayload(array('loves' => $slice->File->Loves->count, 'new_action' => 'love', 'text' => rc__(RokGallery_Config::getOption(RokGallery_Config::OPTION_LOVE_TEXT)))); } catch (Exception $e) { throw $e; } return $result; }
public function getLabel() { $this->_loadAssets(); $html = array(); $class = $this->element['class'] ? (string) $this->element['class'] : ''; $html[] = '<div id="' . $this->id . '" class="spacer-wrapper ' . $class . '">'; if ((string) $this->element['hr'] == 'true') { $html[] = '<hr class="' . $class . '" />'; } else { $text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name']; $text = rc__($text); $class = $this->required == true ? $class . ' required' : $class; $label = '<h6>' . $text . '</h6>'; $html[] = $label; } $html[] = '</div>'; return implode('', $html); }