Inheritance: extends AppModel
Example #1
0
 /**
  * Set a new option.
  *
  * @param   string  $name    No use here, we use option name.
  * @param   Option  $option  The option object to set in this set.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function offsetSet($name, $option)
 {
     $name = $option->getName();
     $aliases = $option->getAlias();
     $this->setAlias($aliases, $name);
     parent::offsetSet($name, $option);
 }
Example #2
0
 /**
  * The getter for $content
  *
  * @return string
  */
 public function getContent()
 {
     $content = parent::getContent();
     if (!isset($content)) {
         $values = $this->values;
         asort($values);
         if (isset($values[''])) {
             $value = $values[''];
             unset($values['']);
             $values = ['' => $value] + $values;
         }
         $content = '';
         $selected = $this->selected();
         /** @var $selected_option Option */
         $selected_option = null;
         foreach ($values as $value => $caption) {
             $html_option = new Option($value, $caption);
             if ($value === $selected) {
                 $html_option->setAttribute('selected');
                 if ($selected_option) {
                     $selected_option->removeAttribute('selected');
                 }
             }
             if ($html_option->getContent() == $selected && !$selected_option) {
                 $html_option->setAttribute('selected');
                 $selected_option = $html_option;
             }
             $content .= strval($html_option);
         }
         $this->setContent($content);
     }
     return $content;
 }
Example #3
0
 /**
  * 
  * @return string
  */
 protected function getCSSClasses()
 {
     $classes = array();
     $classes[] = 'addthis_toolbox';
     $classes[] = 'addthis_default_style';
     if ($this->big->getValue()) {
         $classes[] = 'addthis_32x32_style';
     } else {
         $classes[] = 'addthis_16x16_style';
     }
     $classes[] = 'wfmk_block';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     if ($this->vertical->getValue()) {
         $classes[] = 'vertical ';
     } else {
         // not vertical, so accepting long and counter options
         if ($this->long->getValue()) {
             $classes[] = 'long';
         }
         if ($this->counter->getValue()) {
             $classes[] = 'counter';
         }
     }
     return Tools::ArrayToCSSClasses($classes);
 }
Example #4
0
 /** @test */
 public function it_is_a_correct_object()
 {
     $field = new Option('test', 'Test');
     $field->render();
     $this->assertSame('test', $field->getValue());
     $this->assertSame('administr/form::option', $field->getView());
     $this->assertInstanceOf(AbstractType::class, $field);
 }
 public function test_accessors()
 {
     /** === Test Data === */
     $CURRENCY = 'CUR';
     /** === Call and asserts  === */
     $this->obj->setCurrency($CURRENCY);
     $this->assertEquals($CURRENCY, $this->obj->getCurrency());
 }
Example #6
0
 /**
  * Add inline styles from options (only if has custom option).
  *
  * @since  0.1.0
  *
  * @return void
  */
 public function add_inline_style()
 {
     if ($this->option->has_option('color')) {
         $color = $this->option->get_value('color');
         $custom_css = '#wpadminbar:before { background-color: ' . $color . '}';
         wp_add_inline_style('contextbar', $custom_css);
     }
 }
 public function deleteRowsByID($id)
 {
     global $wpdb;
     $entity = new Entity();
     $option = new Option();
     $entity->deleteById($id);
     $option->deleteByOwnerId($id);
     return $entity && $option;
 }
Example #8
0
 private function buildOptions(&$select, $range)
 {
     foreach ($range as $value) {
         $option = new Option();
         $option->setValue($value, true);
         $option->setLabel($value);
         $select->addOption($option);
     }
 }
Example #9
0
 /**
  * Filter the post type archive permalink.
  *
  * @since 3.1.0
  *
  * @param string $link The post type archive permalink.
  * @param string $post_type Post type name.
  *
  * @return string
  */
 public function post_type_archive_link($link, $post_type)
 {
     $post_type_obj = get_post_type_object($post_type);
     if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) {
         $struct = $this->option->get_front_struct($post_type);
         $link = home_url(user_trailingslashit($struct, 'post_type_archive'));
     }
     return $link;
 }
Example #10
0
 /**
  * 
  * @return string
  */
 protected function getClass()
 {
     if ($this->right->getValue()) {
         return 'class="wfmk_right" ';
     } elseif ($this->left->getValue()) {
         return 'class="wfmk_left" ';
     } else {
         return '';
     }
 }
Example #11
0
/** Automatically selects the right DB handler from options
 * 
 * @param Option $obj_OptionHandler
 * 
 * @return dbHandler
 */
function db_autodefine($obj_OptionHandler)
{
    $str_DbType = $obj_OptionHandler->get('db_type');
    switch ($str_DbType) {
        case 'MySQL':
            require_once PHP_CLASSES_DIR . 'database/MySqlHandler.php';
            return new MySqlHandler();
            break;
    }
}
Example #12
0
 /**
  * 更新Option的值
  */
 private function set2Db($key, $value)
 {
     $item = Option::model()->find("option_name=:option_name", array("option_name" => $key));
     if (!isset($item)) {
         $item = new Option();
         $item->option_name = $key;
     }
     $item->option_value = $value;
     $item->save();
     return $item;
 }
Example #13
0
 /**
  * @return string 
  */
 public function getCSSClasses()
 {
     $classes = array();
     $classes[] = 'gravatar';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     return Tools::ArrayToCSSClasses($classes);
 }
Example #14
0
 /**
  * 
  * @return string
  */
 protected function getCSSClasses()
 {
     $classes = array();
     $classes[] = 'jamendo';
     $classes[] = 'wfmk_block';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     return Tools::ArrayToCSSClasses($classes);
 }
Example #15
0
 /**
  * 
  * @return string
  */
 protected function getClass()
 {
     $classes = array();
     $classes[] = 'wfmk_button';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     $classes[] = 'wfmk_button_' . $this->color->getOutput();
     $classes = Tools::ArrayToCSSClasses($classes);
     return 'class="' . $classes . '"';
 }
Example #16
0
 /**
  * 
  * @return string
  */
 public function getCSSClasses()
 {
     $classes = array();
     $classes[] = 'dailymotion';
     $classes[] = 'wfmk_block';
     $classes[] = 'wfmk_frame';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     return Tools::ArrayToCSSClasses($classes);
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('options', function ($table) {
         $table->increments('id');
         $table->boolean('activate_pn');
         $table->string('basic_name');
         $table->string('basic_pass');
         $table->timestamps();
     });
     $o = new Option();
     $o->activate_pn = 0;
     $o->save();
 }
Example #18
0
 /**
  *
  * Load Plugin modules.
  *
  */
 private function load_modules()
 {
     do_action('sptp_before_load_modules');
     $this->option = apply_filters('sptp_module_option', new Option(), $this);
     $this->admin = apply_filters('sptp_module_admin', new Admin($this->option), $this);
     $this->rewrite = apply_filters('sptp_module_rewrite', new Rewrite($this->option), $this);
     $this->permalink = apply_filters('sptp_module_permalink', new Permalink($this->option), $this);
     $this->option->add_hooks();
     $this->admin->add_hooks();
     $this->rewrite->add_hooks();
     $this->permalink->add_hooks();
     do_action('sptp_after_load_modules');
     do_action('sptp_modules_loaded');
 }
 /**
  * @param string|Option $name
  * @param float|null $price
  * @param StockItem|null $item
  */
 public function addOption($name, $price = null, StockItem $item = null)
 {
     if (!$name instanceof Option) {
         $name = (string) $name;
         if (empty($name)) {
             throw new \InvalidArgumentException('option name cannot be empty');
         }
         $name = new Option($name, $price, $item);
         unset($price, $item);
     }
     if (null !== $this->_findOption($name->getName()) || in_array($name->getStockItem(), $this->_getStockItems(), true)) {
         throw new \InvalidArgumentException('cannot add option with the same name twice');
     }
     $this->options[] = $name;
 }
Example #20
0
 public static function load($thing)
 {
     $product = new Product();
     $product->thing = $thing;
     //members
     $fields_raw = $product->thing->getData();
     $tmpFields = array();
     foreach ($fields_raw as $field) {
         $tmpFields[$field->getKey()] = $field;
     }
     $product->fields = $tmpFields;
     //variants
     $thingVariants = $product->thing->getChildThings("variant");
     $variants = array();
     foreach ($thingVariants as $thingVariant) {
         $variants[] = Variant::load($thingVariant);
     }
     $product->variants = $variants;
     //options
     $thingOptions = $product->thing->getChildThings("option");
     $options = array();
     foreach ($thingOptions as $thingOptions) {
         $options[] = Option::load($thingOptions);
     }
     $product->options = $options;
     return $product;
 }
Example #21
0
 public function source($options)
 {
     foreach ($options as $key => $label) {
         if (is_object($label)) {
             $key = $label->getKey();
             $label = $label->getValue();
         }
         $option = new Option();
         foreach ($this->pushSave as $name => $value) {
             $option->push($name, $value);
         }
         $option->setValue($key);
         $option->setLabel($label);
         $this->parent->addOption($option, $this->position);
     }
 }
 /**
  * Get user generic status data for one or more .
  * @param array $data filter data
  * @return array
  */
 function getUserGenericStatus($data = NULL, $disable_paging = FALSE)
 {
     $data = $this->initializeFilterAndPager($data, $disable_paging);
     $user_id = $this->getCurrentUserObject()->getId();
     if ($data['filter_data']['batch_id'] != '') {
         $batch_id = $data['filter_data']['batch_id'];
         $ugslf = TTnew('UserGenericStatusListFactory');
         $ugslf->getByUserIdAndBatchId($user_id, $batch_id, $data['filter_items_per_page'], $data['filter_page'], NULL, $data['filter_sort']);
         Debug::Text('Record Count: ' . $ugslf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
         if ($ugslf->getRecordCount() > 0) {
             //$status_count_arr = $ugslf->getStatusCountArrayByUserIdAndBatchId( $user_id, $batch_id );
             $this->getProgressBarObject()->start($this->getAMFMessageID(), $ugslf->getRecordCount());
             $this->setPagerObject($ugslf);
             foreach ($ugslf as $ugs_obj) {
                 $rows[] = array('id' => $ugs_obj->getId(), 'user_id' => $ugs_obj->getUser(), 'batch_id' => $ugs_obj->getBatchId(), 'status_id' => $ugs_obj->getStatus(), 'status' => Option::getByKey($ugs_obj->getStatus(), $ugs_obj->getOptions('status')), 'label' => $ugs_obj->getLabel(), 'description' => $ugs_obj->getDescription(), 'link' => $ugs_obj->getLink(), 'deleted' => $ugs_obj->getDeleted());
                 $this->getProgressBarObject()->set($this->getAMFMessageID(), $ugslf->getCurrentRow());
             }
             $this->getProgressBarObject()->stop($this->getAMFMessageID());
             return $this->returnHandler($rows);
         } else {
             return $this->returnHandler(TRUE);
             //No records returned.
         }
     } else {
         return $this->returnHandler(TRUE);
         //No records returned.
     }
 }
Example #23
0
 function _alarm($params)
 {
     $user = $params['user'];
     $channel = $params['channel'];
     $event = $params['event'];
     $time = $params['time'];
     $repeat = $params['repeat'];
     $adata = DB::get()->assoc("SELECT value FROM options WHERE user_id = :user_id AND name = 'alarmdata' AND grouping = 'Alarms'", array('user_id' => $user->id));
     if ($adata == '') {
         $alarms = array();
     } else {
         $alarms = unserialize($adata);
     }
     $time = strtotime($time);
     $output = '<div class="slash">' . htmlspecialchars($params['matches'][0]) . '</div>';
     if ($time == 0) {
         $output .= 'Specified alarm time is <em>invalid</em>.';
     } else {
         $newalarm = array('event' => $event, 'time' => $time - intval((string) Option::get('Time', 'Zone Offset')) * 3600, 'repeat' => $repeat);
         $alarms[] = $newalarm;
         DB::get()->query("DELETE FROM options WHERE user_id = :user_id AND name = 'alarmdata' AND grouping = 'Alarms'", array('user_id' => $user->id));
         DB::get()->query("INSERT INTO options (grouping, name, user_id, value) VALUES('Alarms', 'alarmdata', :user_id, :value)", array('user_id' => $user->id, 'value' => serialize($alarms)));
         $output .= 'Alarm added for ' . date('M j, Y h:ia', $time) . '.';
     }
     DB::get()->query("INSERT INTO presence (data, user_id, type, cssclass, user_to, channel) VALUES (:msg, :user_id, 'system', 'ok', :user_to, '')", array('msg' => $output, 'user_id' => 0, 'user_to' => $user->id));
     return true;
 }
Example #24
0
 /**
  * @covers Kisma\Core\Utility\Option::set
  */
 public function testSetWithArray()
 {
     $_sourceOptions = array('ThisIsCamelCase' => 'camel case', 'this_is_not_camel_case' => 'not camel case', 'one' => 'one', 'eight' => 'eight', 'zero' => 'zero');
     $_targetOptions = array();
     Option::set($_targetOptions, $_sourceOptions);
     $this->assertEquals($_sourceOptions, $_targetOptions);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($quiz_id)
 {
     try {
         DB::beginTransaction();
         $quiz = Quiz::find($quiz_id);
         foreach (Input::get('question') as $input_question) {
             $question_params = array("name" => $input_question['name']);
             $question_validator = Question::validate($question_params);
             if ($question_validator->fails()) {
                 throw new Exception("Question can't be saved");
             }
             $question = new Question($question_params);
             $question = $quiz->questions()->save($question);
             foreach ($input_question['options'] as $value) {
                 $option_params = array("name" => $value['name'], "is_correct" => array_key_exists("is_correct", $value) ? true : false);
                 $option_validator = Option::validate($option_params);
                 if ($option_validator->fails()) {
                     throw new Exception("Option can't be saved");
                 }
                 $option = new Option($option_params);
                 $option = $question->options()->save($option);
             }
         }
         DB::commit();
         return Redirect::to("quizzes/" . $quiz->id . '/questions');
     } catch (Exception $e) {
         DB::rollback();
         //throw new Exception($e);
         return Redirect::to('quizzes/' . $quiz->id . '/questions/create');
     }
 }
Example #26
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $tag = isset($params[1]) && $params[1] == 'tag' ? addslashes(urldecode(trim($params[2]))) : '';
     $pageurl = '';
     //page meta
     $site_title = stripslashes($tag) . ' - ' . $site_title;
     $Tag_Model = new Tag_Model();
     $blogIdStr = $Tag_Model->getTagByName($tag);
     if ($blogIdStr === false) {
         show_404_page();
     }
     $sqlSegment = "and gid IN ({$blogIdStr}) order by date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $pageurl .= Url::tag(urlencode($tag), 'page');
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
 /**
  * Create sitemap
  */
 public static function create()
 {
     // Get pages list
     $pages_list = Pages::getPages();
     // Create sitemap content
     $map = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     $map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     foreach ($pages_list as $page) {
         if ($page['parent'] != '') {
             $parent = $page['parent'] . '/';
             $priority = '0.5';
         } else {
             $parent = '';
             $priority = '1.0';
         }
         $map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . $parent . $page['slug'] . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", (int) $page['date']) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>' . $priority . '</priority>' . "\n\t" . '</url>' . "\n";
     }
     // Get list of components
     $components = Sitemap::getComponents();
     // Add components to sitemap
     if (count($components) > 0) {
         foreach ($components as $component) {
             $map .= "\t" . '<url>' . "\n\t\t" . '<loc>' . Option::get('siteurl') . '/' . Text::lowercase($component) . '</loc>' . "\n\t\t" . '<lastmod>' . date("Y-m-d", time()) . '</lastmod>' . "\n\t\t" . '<changefreq>weekly</changefreq>' . "\n\t\t" . '<priority>1.0</priority>' . "\n\t" . '</url>' . "\n";
         }
     }
     // Close sitemap
     $map .= '</urlset>';
     // Save sitemap
     return File::setContent(ROOT . DS . 'sitemap.xml', $map);
 }
Example #28
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $CACHE = Cache::getInstance();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $author = isset($params[1]) && $params[1] == 'author' ? intval($params[2]) : '';
     $pageurl = '';
     $user_cache = $CACHE->readCache('user');
     if (!isset($user_cache[$author])) {
         show_404_page();
     }
     $author_name = $user_cache[$author]['name'];
     //page meta
     $site_title = $author_name . ' - ' . $site_title;
     $sqlSegment = "and author={$author} order by date desc";
     $sta_cache = $CACHE->readCache('sta');
     $lognum = $sta_cache[$author]['lognum'];
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start_limit = ($page - 1) * $index_lognum;
     $pageurl .= Url::author($author, 'page');
     $Log_Model = new Log_Model();
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
Example #29
0
 function display($params)
 {
     $Log_Model = new Log_Model();
     $options_cache = Option::getAll();
     extract($options_cache);
     $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1;
     $record = isset($params[1]) && $params[1] == 'record' ? intval($params[2]) : '';
     $GLOBALS['record'] = $record;
     //for sidebar calendar
     $pageurl = '';
     //page meta
     $site_title = $record . ' - ' . $site_title;
     if (preg_match("/^([\\d]{4})([\\d]{2})\$/", $record, $match)) {
         $days = getMonthDayNum($match[2], $match[1]);
         $record_stime = emStrtotime($record . '01');
         $record_etime = $record_stime + 3600 * 24 * $days;
     } else {
         $record_stime = emStrtotime($record);
         $record_etime = $record_stime + 3600 * 24;
     }
     $sqlSegment = "and date>={$record_stime} and date<{$record_etime} order by date desc";
     $lognum = $Log_Model->getLogNum('n', $sqlSegment);
     $total_pages = ceil($lognum / $index_lognum);
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start_limit = ($page - 1) * $index_lognum;
     $pageurl .= Url::record($record, 'page');
     $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum);
     $page_url = pagination($lognum, $index_lognum, $page, $pageurl);
     include View::getView('header');
     include View::getView('log_list');
 }
 /**
  * Get menu
  *
  * @param string $category Category name
  */
 public static function get($category = '')
 {
     // Get menu table
     $menu = new Table('menu');
     // Display view
     View::factory('box/menu/views/frontend/index')->assign('items', $menu->select('[category="' . $category . '"]', 'all', null, array('id', 'name', 'link', 'target', 'order', 'category'), 'order', 'ASC'))->assign('uri', Uri::segments())->assign('defpage', Option::get('defaultpage'))->display();
 }